toggling text buttons on and off

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

toggling text buttons on and off

Post by Luke »

I am looking for a way to disable about 5 or 6 text fields by checking a checkbox. I know that you can do this by this method...
document.orderform.textfield.disabled = true
but I just can't get it to work properly.

What I would like even better is if I could make the fields just appear when the textbox is clicked... like with a invisible div or something... suggestions?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

If you want them to appear and disappear, you could just toggle the display property between 'block' and 'none'.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

If I'm not mistaken, isn't it

disable not disabled
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Jcart wrote:If I'm not mistaken, isn't it disable not disabled?
Nope. Disabled. As in, the current state is disabled, not perform the action, disable this control.

http://www.w3.org/TR/REC-html40/interac ... ml#h-17.12
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

nvm... I did this instead...

Code: Select all

function toggleShipping(){
	if(document.order.shipping.checked == 1){
		document.getElementById("shippinglist").style.visibility = "visible";
		document.getElementById("shippinglist").style.height = "auto";
	}
	else{
		document.getElementById("shippinglist").style.visibility = "hidden";
		document.getElementById("shippinglist").style.height = "0px";
	}
}
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Just a note that disabled elements aren't posted. Invisible elements are.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply