www.webdeveloper.com
Results 1 to 4 of 4

Thread: Checkboxes and disappearing/reappearing table

  1. #1
    Join Date
    Jun 2006
    Location
    Kaysville, Utah
    Posts
    2

    Checkboxes and disappearing/reappearing table

    I am designing an order form that includes the following set of checkboxes:

    <input type="checkbox" name="products" value="b_sign" />Branch Sign
    <input type="checkbox" name="products" value="a_sign" />Agent Sign
    <input type="checkbox" name="products" value="fact" />Fact Box
    <input type="checkbox" name="products" value="riders" />Riders

    When somebody checks the final checkbox ("riders") I need a small table show up on the next line:

    <table><tr><td>Riders Description:</td>
    <td><textarea name="riders_desc"></textarea></td></tr></table>

    When the "riders" checkbox is not checked I want the above table (and all its contents) to disappear.

    I have tried putting the table inside a <div> and using Dreamweaver's built-in JavaScripting, but all I can get it to do is to appear when the checkbox is checked (it doesn't disappear if it is unchecked). I also know that using Dreamweaver's built-in functions often results in a messier code than if you just write it yourself.

    If anyone can let me know how to make this table appear and disappear the way I want, I will greatly appreciate it.

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    Given this:

    <table id="ridersTable"><tr><td>Riders Description:</td>
    <td><textarea name="riders_desc"></textarea></td></tr></table>

    Code the following at the end of the BODY section:

    <script type="text/javascript">
    document.getElementById("ridersTable").style.display = "none";
    </script>

    Then, you can code your checkbox as follows:

    <input type="checkbox" name="products" value="riders" onclick="
    if(this.checked) {
    document.getElementById("ridersTable").style.display = "";
    } else {
    document.getElementById("ridersTable").style.display = "none";
    }
    return true;" />Riders

  3. #3
    Join Date
    Jun 2006
    Location
    Kaysville, Utah
    Posts
    2

    Thanks

    Thank you for the help.

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637
    You're welcome.

    Cheers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles