|
-
May 18th, 2005, 03:48 PM
#1
Thread Starter
Junior Member
CheckBox JavaScript Issue
Hi Everyone,
I'm trying to get a textbox filled with a 1 or nothing mattering on if the checkbox has been checked. Can someone tell me what I'm doing wrong here?
Thanks!
James
Code:
<html>
<head>
<script language = "JavaScript">
function initialChkOO2()
{
var chkBox = document.getElementById("chk");
var txtBox = document.getElementById("text");
if(chkBox.Checked)
{
txtBox.value = "1";
}
else
{
txtBox.value = "";
}
}
</script>
</head>
<body>
<form>
<input type = "checkbox" onClick ="initialChkOO2()" id = "chk" name = "chk"/>
<input type="textbox" id = "text" name = "text"/>
</form>
</body>
</html>
-
May 18th, 2005, 04:10 PM
#2
Re: CheckBox JavaScript Issue
This line:
Should be:
Code:
if(chkBox.checked == true)
Remember Javascript is case sensative 
Cheers,
RyanJ
-
May 19th, 2005, 01:23 AM
#3
Member
Re: CheckBox JavaScript Issue
 Originally Posted by sciguyryan
This line:
Should be:
Code:
if(chkBox.checked == true)
Javascript is case sensative, but you don't need == true:
-
May 19th, 2005, 05:45 PM
#4
Re: CheckBox JavaScript Issue
Yea, true but I always put them for readability sake 
Cheers,
RyanJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|