Results 1 to 3 of 3

Thread: Is it possible to set Initial State of a Checkbox from outside the form page?

  1. #1
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is it possible to set Initial State of a Checkbox from outside the form page?

    Wondering if it was possible to set the initial state of a check box via the url link similar to passing a hidden value, but done outside the form page?

    So I have my form page with multiple check box options allowing the user to select one. I also have pages outside the form that I want if they click the url it sets the initial state of one of the check boxes in the form to be selected. Is this possible?

    something like this... http://www.site.com/form.html?variable=selected

    Thanks.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    it's possible with PHP

    PHP Code:
    <?php
    $selected
    $_GET["selected"];
    ?>

    <input type='checkbox' name='apple' <?php if($selected=='apple') { echo "checked"; } ?>/>

    <input type='checkbox' name='orange' <?php if($selected=='orange') { echo "checked"; } ?>/>

    <input type='checkbox' name='banana' <?php if($selected=='banana') { echo "checked"; } ?>/>

    Now, you would have to change the file extention to .php.
    The links to each of those options would be:

    form.php?selected=apple
    form.php?selected=orange
    form.php?selected=banana

    you get the idea...

  3. #3
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a bunch! The site is already php, so it was a breeze.

Bookmarks

Posting Permissions

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