javascript - How do I put id number from select tag to a php link? -


enter image description hereenter image description herecurrently, have far, it's not working:

<form> <select name="patientid" id="patientselect"> <?php $qpatient = mysql_query("select idpatients, firstname, mi, lastname, suffix patients order lastname asc");    while($rowpatient = mysql_fetch_array( $qpatient )) { if(isset($rowpatient['suffix']) && !empty($rowpatient['suffix'])){$suffix = " " . $rowpatient['suffix'];}else{$suffix = null;}             if(isset($rowpatient['mi']) && !empty($rowpatient['mi'])){$mi = " " . $rowpatient['mi'] . ".";}else{$mi = null;}             echo "<option value=" . $rowpatient['idpatients'] . $rowpatient . ">" . $rowpatient['lastname'] . $suffix . ", " . $rowpatient['firstname'] . $mi . "</option>";         }     ?> </select> <a id="updatelink" href="">....</a> <a id="deletelink" href="">....</a> <script  type="text/javascript"> $(document).ready(function(){   $("#patientselect").change(function(){     $("#updatelink").attr('href',"update.php?id="+$("#patientselect").val());     $("#deletelink").attr('href',"delete.php?id="+$("#patientselect").val());   }); }); </script> </form> 

you code works. see here: http://jsfiddle.net/paulpro/euyzp/

changing dropdown's value changes href of links. wanting change links text well?

also side note, shouldn't wrapping code in $(document).ready(), because want script execute <select> added dom.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -