Announcement

Collapse
No announcement yet.

Help with Conditional Content/Objects

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with Conditional Content/Objects

    Hello All,

    I am 100% new to html but I do some small bits of coding in other languages and am relatively tech savvy. That being said I hope someone is able to help me. I am creating forms that our users can access and "submit" to particular email addresses. We currently host our website and edit it through Homestead, so not actual coding but cheater easy stuff =) It does have the ability to add html code to pages. That being said I am looking to make a text box that contains different large sections of text based on check-boxes being checked or not. I would be glad to add more detail if anyone needs, but basically if box 1 is checked, then text box reads: "1 is applicable", if box 1 and 2 are check, then the box reads: "1 is applicable (carriage return) 2 is applicable", and if no box is checked then the box is invisible and/or non-existent.

    I hope this is possible and not too much of an inconvenience.

    Thank you all,

    DarkF1ame

  • #2
    if box 1 is checked, then text box reads: "1 is applicable", if box 1 and 2 are check, then the box reads: "1 is applicable (carriage return) 2 is applicable", and if no box is checked then the box is invisible and/or non-existent.
    HTML Code:
    <!DOCTYPE html>
    <html>
      <head>
        <script>
          function check_box() {
            if (document.getElementById("box1").checked === true) {
                document.getElementById("status1").innerHTML="1 is applicable";
            } else {
                document.getElementById("status1").innerHTML="";
            };
            if (document.getElementById("box2").checked === true) {
                document.getElementById("status2").innerHTML="2 is applicable";
            } else {
                document.getElementById("status2").innerHTML="";
            };
          };
        </script>
      </head>
      <body>
          <div id="status1"></div>
          <div id="status2"></div>
          <input id="box1" type="checkbox" onchange="check_box()">box 1</input>
          <input id="box2" type="checkbox" onchange="check_box()">box 2</input>
      </body>
    </html>

    Comment

    Working...
    X