j4mes_bond25 Posted July 5, 2006 Share Posted July 5, 2006 I've a contact form, on my nearly finished website, allowing viewers to send the data, which I've validated with different validation rule depending on the data required for a field itself.Website itself can be seen on: http://members.lycos.co.uk/darsh25/AllInclusiveWebDesign/contact.phpProblem is with last 2 fields i.e. "Reply Required" AND "How would you like to be contacted?"If user press the submit button, I want the "filled" fields remain same, hence, making them NOT to re-type what they's already done. I wish to do the same for these 2 options as well, hence whichever radio button they'd chosen, after pressing submit, if they mis-filled any fields (for example, "e-mail"), then I want the option chosen in 2 radio buttons staying same i.e. whatever they'd chosen Problem is, after pressing "Submit" the radio button options for these 2, ALWAYS goes to the "second option" regardless of the option chosen ??? This makes them RE-chose the radio button option.Related code[code=php:0]<tr id="contactTable"><td id="contactTable">Reply Required:</td><td id="contactTable"><input type="radio" name="reply" value="Yes" checked="checked"/>Yes<input type="radio" name="reply" value="No" <?php if ($reply="No") echo "checked='checked'"; ?>/>No</td></tr><tr id="contactTable"><td id="contactTable">How would you like to be contacted <span class="italic">(if required)</span>?<br/><br/></td><td id="contactTable"><input type="radio" name="contact" value="Email" checked="checked"/>E-mail<input type="radio" name="contact" value="Telephone" <?php if ($contact="Telephone") echo "checked='checked'"; ?>/>Telephone</td></tr>[/code] Wonder why's this happening ??? Can anyone help ??? Quote Link to comment Share on other sites More sharing options...
toplay Posted July 5, 2006 Share Posted July 5, 2006 I'll do one to get the idea, and you can fix the other. You are using one equal sign instead of two (==), plus you need to do the same thing on the 'Yes' option.// Assume you have something like this set already (use $_GET or $_POST):$reply = isSet($_REQUEST['reply']) ? $_REQUEST['reply'] : 'Yes'; // Set default...<td id="contactTable"><input type="radio" name="reply" value="Yes" <?php if ($reply == "Yes") echo 'checked="checked"'; ?>/>Yes<input type="radio" name="reply" value="No" <?php if ($reply == "No") echo 'checked="checked"'; ?>/>No</td> 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.