Learn how to a build a cloud-first strategyRegister Now

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

show/hide DIV based on checkbox click

I have a checkbox in my form. If the checkbox is checked, I need to show a div tag. If it is unchecked, I need to hide the div tag.

Please help.

0
sshivanna
Asked:
sshivanna
  • 2
1 Solution
 
sshivannaAuthor Commented:
sorry, I need to accomplish this using Jqeury.
Thank you
0
 
InsoftserviceCommented:
Hi,
I hope u have only one chk box.

<input type="checkbox" name="foo" value="bar" />

var value =  $('input[name=foo]').is(':checked') // to check whether its true or false 1st method
var value = $('input[name=foo]').attr('checked') // to check whether its true or false 2nd method
if(value ==true){
$('#divid').show();
}
else{
$('#divid').show();
}
0
 
sshivannaAuthor Commented:
Thank you, the idea worked. I didn't realize that I can use a combo of javascript and jquery.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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