Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Using PHP validation with JavaScript

    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.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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:

    PHP Code:
    <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.
    Last edited by glenngv; 07-08-2005 at 06:48 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •