Amiga.org

Coffee House => Coffee House Boards => CH / Science and Technology => Topic started by: Brian on May 01, 2007, 02:57:33 PM

Title: Need help with a Javascript to hide form items.
Post by: Brian on May 01, 2007, 02:57:33 PM
I'm in need of a javascript that can hide several Form items (both checkboxes and option lists) so that only a small portion of the original form is visible but so that all the differen form items states (checkbox being pre-checked and option list being pre-selected) are still passed through when submitting.

I'm thinking it might be able to be done with a "Style value" to not interfear with the different names and values of the items in question?
Title: Re: Need help with a Javascript to hide form items.
Post by: motorollin on May 01, 2007, 07:26:39 PM
I'm not sure checkboxes and selection boxes have hidden/visible attributes. You could just create a hidden form control containing the value you want to post:



[EDIT]
The W3C's page on forms doesn't mention any hidden/visible attribues for any form elements other than the example above. See here (http://www.w3.org/TR/html4/interact/forms.html).
[/EDIT]

--
moto
Title: Re: Need help with a Javascript to hide form items.
Post by: Karlos on May 01, 2007, 07:37:48 PM
Try setting e.style.display="none" / "" (where e is the form element object handle) to hide an element at the JS/CSS1 level. You can also use e.style.visibility="hidden" / "visible" where CSS2 is available.

Better still, wrap the form element in a
or a and modify the style.display / .visibility property of that.

@Motorollin

Strictly speaking, any element that can take a style attribute can be made visible or invisible by modifying the element's style property itself, rather than the element, which as you say, is unlikely to have a visibility property of its own.
Title: Re: Need help with a Javascript to hide form items.
Post by: motorollin on May 01, 2007, 07:45:37 PM
Bah! CSS is witchcraft!

--
moto
Title: Re: Need help with a Javascript to hide form items.
Post by: Karlos on May 01, 2007, 07:50:49 PM
:lol: