javascript - dropdown select to go url not working in while loop php -
<?php $sql = "select * letter societyn='" . $_session['socityname'] ."' "; $result = mysql_query($sql); $i=1; while($row=mysql_fetch_array($result)){ ?> <?php $id = $row['id']; $dater = $row['date']; $flatnonam = $row['flatno_name']; $addr = $row['adress']; $subject = $row['subject']; $body = $row['body']; $soci = $row['societyn']; $refnum = $row['refno']; $letterh = $row['letterh']; // split "dd-mm-yyyy" array of 3 elements $ddate = explode("-", $dater); // retrieve values $month = $ddate[1]; // mm $day = $ddate[2]; // dd $year = $ddate[0]; // yyyy { ?> <tr> <td><?php echo $day.'/'.$month.'/'.$year; ?></td> <td><?php echo $flatnonam; ?></td> <td><?php echo $letterh; ?></td> <td><?php echo $addr; ?></td> <td><?php echo $subject; ?></td> <td><?php echo $soci; ?></td> <td><?php echo '#'.$refnum; ?></td> <td> <select name="menu1" id="menu1"> <option value="" selected>pick website</option> <option value="letter/letter_print.php?id=<?php echo $row['id']; ?>">without letter head</option> <option value="letter/letter_print_nohead.php?id=<?php echo $row['id']; ?>">letter head</option> </select> </td></tr> <?php }?> <?php echo "<br>"; $i++; } ?> <!--this java script--> <script type="text/javascript"> var urlmenu = document.getelementbyid( 'menu1' ); urlmenu.onchange = function() { window.open( this.options[ this.selectedindex ].value, '_blank','width=595,height=842,directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no'); }; </script>
this code .only 1st 1 option working other not working. please in trouble. 2 days. or give solution. in 1 id how use options. trying 2 days not working.
as mentioned change id
class
since have multiple select
. define onchange
listener of them:
var urlmenus = document.queryselectorall('.menu1'); for(var = 0; < urlmenus.length; i++) { urlmenus[i].onchange = function () { window.open(this.options[this.selectedindex].value, '_blank', 'width=595,height=842,directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no'); }; }
Comments
Post a Comment