tqla Posted December 6, 2007 Share Posted December 6, 2007 After a form is submitted my Validation looks for errors. When it finds them it redisplays the form. I don't want my users to have to re-input their information so the code in the Text Fields has this as the value "<?php echo @$fieldname ?>" (fieldname replaced with proper field name). This works fine and their input is retained and redisplayed but this seems to work only for text fields, and not for Drop Downs, Radial Buttons, Radial Groups and Check boxes. Is there a way to do this for these too? Thanks. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 6, 2007 Share Posted December 6, 2007 Use the $_POST array, it should work. Quote Link to comment Share on other sites More sharing options...
JacobYaYa Posted December 6, 2007 Share Posted December 6, 2007 You will need to add something like 'echo (isset($_POST[checkbox name])) ? 'checked="checked" : '';' to your checkboxes. Look up the equivalent attribute for dropdowns etc. Quote Link to comment Share on other sites More sharing options...
tqla Posted December 6, 2007 Author Share Posted December 6, 2007 Thanks! Quote Link to comment Share on other sites More sharing options...
tqla Posted December 6, 2007 Author Share Posted December 6, 2007 I found the answer in a book by David Powers. Here's the jist of it in case anybody needs to know. This sample is a YES or NO dropdown. The $blank_array is the message that appears when a field has no data. <td align="right"> <p>Interest in speaking with a rep about solving your problem?</p> </td> <td align="left" valign="top"> <select name="interest" id="interest"> <option value="No Reply" <?php if (!$_POST || $_POST['interest'] == 'No reply') { ?> selected="selected" <?php } ?> >Select</option> <option value="Yes" <?php if (isset($blank_array) && $_POST['interest'] == 'Yes') { ?> selected="selected" <?php } ?> >Yes</option> <option value="No" <?php if (isset($blank_array) && $_POST['interest'] == 'No') { ?> selected="selected" <?php } ?> >No</option> </select></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.