It does not load the php file correctly

0

Hello I am updating a web page, in which I have a form, the necessary data are filled in and with javascript, at the moment of sending the form, it does not open or does not detect the link well.

At the moment of clicking on the edit button, the link of the page that I need to open is not opened correctly.

The browser bar appears:

  

link $ user% 20?% 3E

In case everything went well, the browser bar should show:

  

link

The error I think is in this line

   document.autform.action = "EditarPruebaFrames.php?usuario=<?php echo $usuario ?>";

   function EditarPrueba(){
                var select_prueba = document.getElementById("prueba");
                var prueba = select_prueba.value;
                
                if ((prueba == "") || (prueba == null))
                    alert("No ha seleccionado ninguna prueba");
                else
                {
                     document.autform.action = "EditarPruebaFrames.php?usuario=<?php echo $usuario ?>";
                     document.autform.method = "POST";
                    document.autform.submit();
                    document.autform.action = "";
                    /*
                     document.getElementById("autform").action = "EditarPruebaFrames.php?usuario=<?php echo $usuario; ?>";
                    document.getElementById("autform").method = "POST";
                    document.getElementById("autform").submit();
                    document.getElementById("autform").action = "";*/
                }
            }
            
  <form  class = "form-horizontal" name="autform" id="autform" action="<?php $_SERVER['PHP_SELF']?>" method="post" target="EDICION">
	<!--
		Código del que se obtiene la "prueba"
	-->
	<input  class="btn btn-primary" type="button" name="Editar" id="Editar" value="Editar" class="normal_text" onClick= "EditarPrueba();">
 </form>

Any way to redirect the php file correctly?

thanks.

    
asked by Javr 03.08.2017 в 10:18
source

1 answer

0

I think it's something that does not interpret the php well. However, in the form you have a

action="<?php $_SERVER['PHP_SELF']?>

If it's working, right?

I think you could fix it by having the EditTest function have a parameter that is that user's id. Something like:

function EditarPrueba(userId){
                var select_prueba = document.getElementById("prueba");
                var prueba = select_prueba.value;

                if ((prueba == "") || (prueba == null))
                    alert("No ha seleccionado ninguna prueba");
                else
                {
                     document.autform.action = "EditarPruebaFrames.php?usuario="+userId;
                     document.autform.method = "POST";
                    document.autform.submit();
                    document.autform.action = "";
                    /*
                     document.getElementById("autform").action = "EditarPruebaFrames.php?usuario=<?php echo $usuario; ?>";
                    document.getElementById("autform").method = "POST";
                    document.getElementById("autform").submit();
                    document.getElementById("autform").action = "";*/
                }
            }

And replace the input with:

<input  class="btn btn-primary" type="button" name="Editar" id="Editar" value="Editar" class="normal_text" onClick= "EditarPrueba('<?php echo $usuario ?>');">
    
answered by 03.08.2017 в 10:46