Javascript onchange for dropdown value problem

I have 2 frames of php files, first it's a call to topFrame and the bottom is mainFrame. In topFrame, I have a php file with a dropdown value, onchange I would like to reload this frame with another php file.

Below is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>RATEMASTER</title> <script type="text/javascript"> function showsupli(sta) { alert ("sta"); if (sta == 'Yes') { window.open('ratesupli.php,'topFrame'); } } </script> </head> <body> <? echo "<form name='f1'>"; echo "<table width='730' border='0' align='center' cellpadding='0' cellspacing='1'>"; echo " <tr>"; echo " <td><span class='style3'>Suplimentry Invoice</span></td>"; echo " <td>"; echo "<select name='supli' onchange=\"showsupli(this.value);\"><option value=0>No</option>"; echo "<option value=1>Yes</option>"; echo "</select>";// Closing of list box echo "</td>"; echo " </tr>"; echo "</table>"; echo "</form>"; ?> </body> </html> 
+4
source share
2 answers

The problem is that your parameter values ​​are 1 and 0 , but in your Javascript you are looking for Yes .

Change to:

 if (sta == '1') 

The selected value a <select> is the selected <option> value , not the text.

You also have a syntax error, you forgot to close the quote after ratesupli.php , use:

 window.open('ratesupli.php','topFrame'); 
0
source

html CHANGE

 <option value='0'>No</option> <option value='1'>Yes</option> 

Javascript change

 function showsupli(sta) { alert ("sta"); if (sta == '1') { window.open('ratesupli.php','topFrame'); } } 
0
source

All Articles