Welcome, Guest. Please login or register.

Author Topic: Need help with a Javascript to hide form items.  (Read 1113 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline BrianTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2003
  • Posts: 1604
    • Show only replies by Brian
    • http://www.syntaxsociety.se
Need help with a Javascript to hide form items.
« 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?

Offline motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Need help with a Javascript to hide form items.
« Reply #1 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.
[/EDIT]

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Need help with a Javascript to hide form items.
« Reply #2 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.
int p; // A
 

Offline motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Need help with a Javascript to hide form items.
« Reply #3 on: May 01, 2007, 07:45:37 PM »
Bah! CSS is witchcraft!

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Need help with a Javascript to hide form items.
« Reply #4 on: May 01, 2007, 07:50:49 PM »
:lol:
int p; // A