View Full Version : Using PHP validation with JavaScript

07-07-2005, 10:45 PM

A little problem I am facing. What is happening is that a user selects a radio button and then a JavaScript displays the appropriate fieldset with more options for the user to pick.

Upon submitting the form, there is a PHP validation script that is run and if there is an error the page reloads with the error message, but my fieldset that was displayed on the prior page does not show unless I click the radio button again (The radio button is marked already on this page).

My question is:
How do I get my PHP validation to recognize the JavaScript and leave the users selection checked and shown if there is an error? Any help would be much appreciated. Thanks.

07-08-2005, 06:41 AM
In PHP, when that radio button is checked, set the CSS display of the corresponding fieldset to 'block' or to the appropriate CSS class name. I'm assuming you're using the display property in CSS to show or hide the fieldset. Something like this:

<style type="text/css">
.show {display:block;}
.hide {display:inline;}
if radio button is checked
<fieldset class="show">
<fieldset class="hide">
I don't know PHP, so the syntax might be wrong. But you'll get the idea.