Any Javascript geeks around?!

Sie

Gold Level Poster
So i have a little issue which i cant seem to sort.

basically, i need to use a piece of javascript to turn a piece of text from Red and bold to Black and non bold once the user clicks on a check box.

problem is i just cant seem to get it to work and have no clue on where to start :<

this is all ive got so far

<p style="color: #FF0000; font-weight: bold;">I have read and agree to the terms and conditions
<input type="checkbox" id="termsChkbx" /></p>

which ofc is just the HTML "/
 

Rakk

The Awesome
Moderator
Is this on an aspx page - in which case you can do it in the code behind page, or javascript on the page or javascript in a different js file.
Or are you using something else?
 

Sie

Gold Level Poster
nah its just on a general web page, no ASP or separate js file. its all on page.
 

Rakk

The Awesome
Moderator
Something like:
<html>
<script type="text/javascript">
function ig_onchange() {
var form = document.forms['InputForm'].elements;
if (form.ig.checked) {
form.labelId.color="Black";
form.labelId.fontStyle="Normal";
} else {
form.labelId.color="Red";
form.labelId.fontStyle="Bold";
}
}
</script>
<body>
<form name="InputForm" id="InputForm">
<p><input type="checkbox" name="ig" onclick="ig_onchange()"></p>
<p><label id="labelId">TextHere</label></p>
</form>
</body>
</html>
may work, but I haven't actually checked to see if it works, you may have to tweak it a bit, but it'll be something like that.
 
Last edited:
Top