php - Jquery not getting dynamic dropdown value -
in code when selecting 1st dropdown getting value in next not getting value jquery ..
<?php $con=mysql_connect('localhost','root','root'); mysql_select_db('alok',$con); ?> <!doctype html> <html> <head> <title></title> <script type="text/javascript" src="jquery.min.js"></script> </head> <body> <form method="post"> <table width="100%"> <tr> <td>id</td> <td>item</td> <td>status</td> <td>dropdown</td> </tr> <?php $query="select * jain"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ ?> <tr> <td><?php echo $row['id']; ?></td> <td><?php echo $row['gift']; ?> </td> <td><?php if($row['status']==='0'){echo 'pending';}elseif($row['status']==='1'){echo 'recieved';}else{ echo 'rejected';} ?></td> <td> <select name="status" id="status"> <option value="0">pending</option> <option value="1">recieved</option> <option value="2">rejected</option> </select> </td> </tr> <?php } ?> </table> </form> </body> </html> <script type="text/javascript"> $(document).ready(function(){ $('#status').change(function(){ var status=$('#status option:selected').val(); alert(status); }) }) </script>
when selecting first dropdown:
when selecting second dropdown not getting alert:
what doing wrong here please let me know newbie here
use different id
select. other selected value.
<select name="status" id="status1"> <option value="0">pending</option> <option value="1">recieved</option> <option value="2">rejected</option> </select> <select name="status" id="status2"> <option value="0">pending</option> <option value="1">recieved</option> <option value="2">rejected</option> </select>
Comments
Post a Comment