...

View Full Version : Using PHP validation with JavaScript



apowers20
07-07-2005, 09:45 PM
Hi,

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.

glenngv
07-08-2005, 05: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:


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum