Results 1 to 2 of 2

Thread: when a checkbox is checked show a div

  1. #1
    Join Date
    Aug 2014

    when a checkbox is checked show a div


    I'm trying to show some div's by using some checkboxes

    I have found a good code but it is HTML

    The checkboxes must be in a php code because it depends on an other value if they are shown yes or not

    Her is te HTML code:

    <!DOCTYPE html>
    <html lang="en">
    <meta charset="utf-8" />
    <title>Checkboxes shown </title>

    function showMe (it, box) {
    var vis = (box.checked) ? "visible" : "hidden";
    document.getElementById(it).style.visibility = vis;
    <input type="checkbox" name="c1" onclick="showMe('div1', this)" checked>Show Hide Checkbox for div 1
    <input type="checkbox" name="c1" onclick="showMe('div2', this)" checked>Show Hide Checkbox for div 2
    </form><div id="div1">
    <h3 align="center"> this is the first div </h3>
    <table border=1 id="t1">
    <td>i am here!</td>
    </div><div id="div2">
    <h3 align="center"> This is the second div </h3>
    <table border=1 id="t1">
    <td>i am here for the second one!</td>


  2. #2
    Join Date
    Jul 2013
    Voorheesville NY USA
    Regardless of the "other" codes, you need to write some JS to react to the checkbox click (onclick event). With that you can check any other field you want to check and then show your div.
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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