Javascript help please (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


Tailslide -> Javascript help please (4/15/2008 8:50:17)

Hi all

I've run into a Javascript problem and I've confused myself (happens a lot!). I'm hoping someone out there can point me in the right direction.

I'm using this script to show/hide a ton of form fields depending on whether a checkbox is checked:

<script type="text/javascript">
function toggle() {
if (document.getElementById) {
if (document.getElementById("person_subscription_birthday_club").checked == true) {
document.getElementById("birthdayclub").style.display = "block";
} else {
document.getElementById("birthdayclub").style.display = "none";
}
}
}

</script>


With this:

onclick="toggle();"


in the checkbox input itself.

All fine and dandy - works very nicely thank you.

The problem is on the otherwise identical - update profile form, I want to check onload if the checkbox in question is already checked and either show or hide the rest of the stuff accordingly. Then also have the current functionality.




Tailslide -> RE: Javascript help please (4/15/2008 9:16:36)

[8|] Course I worked it out by myself 5 minutes after posting here... ignore me.




mar0364 -> RE: Javascript help please (4/15/2008 9:41:37)

I use to do that in the "ASP Database" section all the time. LOL




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
7.617188E-02