Reputation: 213
Currently, this is what I have so far, but it's not working:
<form>
<select name="patientID" id="patientSelect">
<?php
$qPatient = mysql_query("SELECT idpatients, firstName, mi, lastName, suffix FROM patients ORDER BY 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>
Upvotes: 0
Views: 213
Reputation: 141887
You code works. See it here: http://jsfiddle.net/Paulpro/Euyzp/
Changing the dropdown's value changes the href of the links. Are you wanting to change the links text as well?
Also just a side note, you shouldn't be wrapping that code in a $(document).ready(), because you want that script to execute as soon as the <select>
is added to the DOM.
Upvotes: 1