I have this block of code:
What I'd like is if the user selects the "Yes" radio button, it fires the JavaScript that changes the "display:none" on the following tr so it's displayed. If the question were presented in a link instead of a radio button, the appropriate syntax would be:PHP Code:<tr class="brownLabels">
<td><label for="isGeneric">Is this a generic drug? </label></td>
<td><input type="radio" name="f_addMeds[isGeneric]" value="1" <?php if(isset($f_addMeds["isGeneric"]) && $f_addMeds["isGeneric"] == "1") echo "checked='checked'"; ?> /> Yes
<input type="radio" name="f_addMeds[isGeneric]" value="0" <?php if(isset($f_addMeds["isGeneric"]) && $f_addMeds["isGeneric"] == "0") echo "checked='checked'"; ?> /> No </td>
</tr>
<tr class="brownLabels" id="generic" style="display:none; ">
<td><label for="genericFor">Generic for: </label></td>
<td><input type="text" id="genericFor" name="f_addMeds[genericFor]" value="<?php if(isset($f_addMeds["genericFor"])) echo $f_addMeds["genericFor"];?>" /></td>
</tr>
Notice that to be parallel with what the JavaScript does, if the user changes their mind after they've selected "Yes" and goes back and selects "No", the subsequent tr would disappear again.HTML Code:<a href="#" id="isGenericQuestion" onclick="javascript:showHide('generic', 1); showHide('isGenericQuestion', 0); ">Click here if this is a generic drug.</a>
How can I write PHP to extract the values from the radio buttons to trigger the JavaScript? Or if there's a way to do the same thing using only PHP, that's fine, too.






Bookmarks