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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript not working

Status
Not open for further replies.

Wolfie7873

Technical User
Jan 15, 2004
94
US
Forgive me that this isn't strictly AJAX, but I need to get the script working before I can starting using the request object to do the dirty work.

I'm trying to enable a text input if a checkbox is checked. The default state on page load should be disabled.

Here is my code

Code:
<script type='text/javascript'>
document.getElementById('count_box').disabled = true;

function chgCountBox(str)
{
if (str=='true')
  { 
  document.getElementById("count_box").disabled=false;
  document.getElementById("countprompt").innerHTML="How Many?";
  }
if (str=='false')
	{
	document.getElementById("count_box").disabled=true;
	document.getElementById("countprompt").innerHTML="";
	}
}
</script>

</head>
<body>

<form> 
<input type="checkbox" id="cbox1" onchange="chgCountBox(this.checked)"> 
Create Correlation(s): 
<span id="countprompt"></span>
<input type='text' id='count_box'>
</form>

When I render the page, the textbox is enabled and changing the state of the checkbox has no effect.

What gives?
 
Why not ask this in forum216 if it's nothing to do with AJAX?

Personally, I wouldn't treat the value as a string, but as a boolean, although seeing as JS is flexible about types, it probably doesn't matter that much.

But anyway - forum216 is your best bet, and a better forum for non-AJAX JS questions.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top