View Full Version : OnChange event problem

01-15-2012, 04:34 PM
Hi All,

Need a bit of help here, need this SELECT to submit the page and end up at the below URL, correctly passing the GET values through the string.

<select name="dir-fact-misma" id="dir-fact-misma" class="text100" tabindex="" onChange="alta_nueva.action='alta.php?page=p2#alta'; return true;">
<option value="Si" <?php if(!isset($_POST['dir-fact-misma']) || $_POST['dir-fact-misma'] == 'Si') print "Selected='Selected '"; ?>>Si</option>
<option value="No" <?php if(isset($_POST['dir-fact-misma']) && $_POST['dir-fact-misma'] == 'No') print "Selected='Selected '"; ?>>No</option>


the form in which this SELECT is placed needs to be submitted so that other fields in the form are not lost, they are saved in Session Variables.

the same javascript but activated through an onclick event works perfect elsewhere in the same form with the following code, i think its the onChange that doesn't work for some reason.

<input name="p1" type='submit' id="p1" onclick="alta_nueva.action='alta.php?page=p1#alta'; return true;" value='1' />

the page is programmed in PHP.

Any help is appreciated.

Old Pedant
01-16-2012, 02:10 AM
What is alta_nueva??

If that is the name of the <form> then you would need to use document.alta_nueva

But also, if it is the <form> that encloses the given <select> or <input>, then you should be coding it as simply this.form.....


<select name="dir-fact-misma" class="text100"
onchange="this.form.action='alta.php?page=p2#alta'; this.form.submit();">

There's almost never a reason to give an id to <form> fields. The name is needed, else the field won't be seen by the PHP code. But the id adds nothing useful to the mix.