Styles2304 Posted June 3, 2009 Share Posted June 3, 2009 I'm populating a form and, in the process, trying to show/hide certain divs based on whether or not certain radio buttons are marked as checked. Am I missing something that is causing the toggleDisplay code being called by the PHP to not execute? <input type="radio" name="Mil_Status" value="ETS" onclick="toggleDisplay('show', 'Mil_FromTo', 'main'); toggleDisplay('hide', 'Mil_Serving', 'main'); toggleDisplay('hide', 'Mil_Discharge', 'main');" <?php if ($Mil_Status == 'ETS') { echo 'Checked'; ?>> <?php echo "<script type='text/javascript'>toggleDisplay('show', 'Mil_FromTo', 'main'); toggleDisplay('hide', 'Mil_Serving', 'main'); toggleDisplay('hide', 'Mil_Discharge', 'main');</script>"; } ?> ETS or Retired <br> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 3, 2009 Share Posted June 3, 2009 Your input tag is never closed. And I don't know how you want that function to trigger, so this is the best I can do. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted June 3, 2009 Author Share Posted June 3, 2009 Your input tag is never closed. And I don't know how you want that function to trigger, so this is the best I can do. Yes it is, look closely. Right after "checked", I close the php tag and then close the input tag. I'm trying to trigger the function right there . . . that's what I'm asking for help with. The function is defined in a seperate file and loaded in the head but I don't know how to trigger it. Quote Link to comment Share on other sites More sharing options...
kickstart Posted June 3, 2009 Share Posted June 3, 2009 Yes it is, look closely. Right after "checked", I close the php tag and then close the input tag. I'm trying to trigger the function right there . . . that's what I'm asking for help with. The function is defined in a seperate file and loaded in the head but I don't know how to trigger it. Only if $Mil_Status == 'ETS' . Otherwise the closing tag is not output (it is inside the curley brackets for the if statement). All the best Keith Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted June 3, 2009 Share Posted June 3, 2009 The function is defined in a seperate file and loaded in the head but I don't know how to trigger it. At the very bottom of your output, immediately before the closing </html> tag, do echo "<script language='javascript' type='text/javascript'>"; echo " toggleDisplay('show', 'Mil_FromTo', 'main');"; echo " toggleDisplay('hide', 'Mil_Serving', 'main');"; echo " toggleDisplay('hide', 'Mil_Discharge', 'main');"; echo "</script>"; or whatever variants you need Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.