jfourman Posted August 20, 2006 Share Posted August 20, 2006 I'm hacking at an ecommerce template to make some minor customizations.I am having trouble validating the value of a radio button in a form. I can print the value in the PHP code and it displays correctly. I just don't know how to write the "if" statement in the script to evaluate the value.The code below is just a test to display an alert message; but if the "Image Upload" button is selected, it doesn't display the alert. Do I need to do a string function on the "updatetype" variable first? The printf statement prints "Image Upload". I get the script and form to work if I am testing the value of a text box input. It's the radio button that is giving me problems.Script: (I left out the JS header since my message wouldn't post with it included):<!--function checkform(theForm){ if (theForm.updatetype.value == "Image Upload") { alert("<?php print "Radio Button is Image Upload."?>"); return (false); } return (true);}//--></script><form action='orderupdate.php' method="POST" onsubmit="return checkform(this)"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input type="radio" name="updatetype" value="<? echo("Image Upload"); ?>"> Upload an image</label></td> </tr> <tr> <td><input type="radio" name="updatetype" value="<? echo("Change Request"); ?>"> Request a change to my order</label></td> </tr> <tr> <td><input type="radio" name="updatetype" value="<? echo("Cancellation Request"); ?>"> Cancel my order</label></td> </tr> <tr> <td> <input type='submit' name='send' value='Send Order Update'> </td> </tr> </table></form><?php printf ($updatetype);?>Thank you for your help. Quote Link to comment Share on other sites More sharing options...
radalin Posted August 21, 2006 Share Posted August 21, 2006 Try giving an id to your updatetype's like instead of only names like:<input type="radio" name="updatetype" id="updatetype" value="<? echo("Change Request"); ?>"> 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.