Radio button/Checkbox value passing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerim79

    Radio button/Checkbox value passing

    I have a simple 3 page registration form. One form, one "data
    validation" script and one "insert into database" script. The customer
    bounces back and forth from the form to the verification script until
    the data is all correct. (When I say bounces, I mean logically. All the
    customer ever sees is the registration form, plus or minus error
    messages.)

    The problem I am having, is that if verification fails, the customer is
    redirected to the form. I am able to pass the input values from the
    "data validation" script back to the registration form using this
    method:
    <input id="Name" name="Name" type="text" value="<?php echo $Name ?>>

    It works well, but I don't know how to pass the variable of a radio
    button or check box back. I remember in javascript and other similar
    languages you could do something like:
    checkbox.value= checked

    Is there a way to do this in PHP? What I am attempting to do, is make
    is so that if the customer chooses YES on a radio button and the form
    is submitted,; ifthey are sent back to the form to correct an error,
    the radio button YES is still checked. I am not just trying to pass the
    variable, but to also make it select the right option when it goes
    back.

    (Or is this just more of an HTML question, at which point I will ask
    elsewhere)

  • Gary Hasler

    #2
    Re: Radio button/Checkbox value passing

    Jerim79 wrote:
    ...What I am attempting to do, is make
    is so that if the customer chooses YES on a radio button and the form
    is submitted,; ifthey are sent back to the form to correct an error,
    the radio button YES is still checked...
    AFAIR you have to use a condition to write "checked" into the tag if the
    submitted value for the radio button group matches this button's value:
    eg
    <input type="radio" name="whatever" value="Yes"
    <?php if ($whatever.valu e=="Yes") echo " checked";?>
    >
    (I hope I got that right; working from memory!)

    Comment

    Working...