Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

hide/un-hide section (on check/un-check checkbox)

I have a list of checkboxes that asking users for input, the last one will be "Others" - when users selected this checkbox, it'll show another textarea so they can type in some text ... when they un-checked the box, the textarea should be disappear.

<form action = "test.asp" method="post">
   <input type="checkbox" name="name1" value="value1"> Value1
   <input type="checkbox" name="name2" value="value2"> Value2
   <input type="checkbox" name="name3" value="others"> Others
    below will be shown only when user selected "Others", disappear when uncheck.
    <textarea name="text2Enter" rows="3" cols="30"></textarea>

</form>

Please help :) thank you very much,
0
tlp560
Asked:
tlp560
  • 2
1 Solution
 
BatalfCommented:
<form action = "test.asp" method="post">
   <input type="checkbox" name="name1" value="value1"> Value1
   <input type="checkbox" name="name2" value="value2"> Value2
   <input type="checkbox" name="name3" value="others" onclick="document.getElementById('text2Enter').style.display=(this.checked?'inline':'none')"> Others
    below will be shown only when user selected "Others", disappear when uncheck.<br>
    <textarea style="display:none" id="text2Enter" name="text2Enter" rows="3" cols="30"></textarea>

</form>
0
 
wimthepimscakeCommented:
or <input type="checkbox" name="name3" value="others" onclick="document.getElementById('text2Enter').style.display=(this.checked?'blocked':'none')">
0
 
BatalfCommented:
you probably mean "block" and not "blocked"!?
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now