Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

emailing form

Status
Not open for further replies.

d0s

Programmer
Apr 15, 2004
48
US
im making a form for people to fill out and submit. when they click the submit button it emails me the information thru php. i got everything working, but when i decided to change it a little i ran into a problem i can't seem to figure out. How do i set variables for checkboxes so when they click it, it will set the variable and if they deselect it, it will unset the variable. i was reading threads and saw one said to post in javascript forum so thats why im posting here. So basically what i want to do is when they click the checkbox, it sets the variable and if the deselect it, it will unset the variable.
 
Hope the following helps,
Code:
<script>
[COLOR=green]//the variable you wanna set or reset[/color]
var aVariable;
function assignVar() {
  if (document.forms["fm"].chBox.checked) {
    aVariable=1;
  } else {
    aVariable=0;
  }
}
</script>

<body>
<form name="fm">
<input type="checkbox" name="chBox" onClick="assignVar()">Assign Variable
</form>
</body>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top