Forum OpenACS Q&A: javascript for hiding/showing form elements

I want to integrate a js into survey_simple that hides a form element
whenever a user doesn't have to fill it out. Whenever the user wants
to fill it out anyways, he just clicks on a button and the form
element opens up.

I found an very good example, but it only works on IE:

http://www.anders.com/projects/javascript/form-dynamic_hide/

This example also works on Mozilla, but the form gets exchanged with
whitespace and not with nothing:

http://www.js-examples.com/example/?ex=97&mode=2

Does anyone already hava such an implementation or knows how to merge
the two little example scripts?

Collapse
Posted by Jonathan Ellis on
it would be a lot easier to leave the input visible, but disabled.  good luck. :)
Collapse
Posted by Andrei Popov on
how about putting form elements onto different layers with <div> and then stacking them & changing visibility props?  this wont, however, work in many (if not all) older browsers.
Collapse
Posted by David Kuczek on
I found a solution that works with IE, Netscape and Mozilla:

Add Questions
Question 1   (open close)

Question 2   (open close)
Collapse
Posted by David Kuczek on
Funny, I thought that our bboard would cut out scripts, but noap...
Collapse
Posted by Jonathan Ellis on
I don't think the 3.x bboard calls util_close_html_tags out of the box.  (And you'd still need to add "syn(SCRIPT) discard" to the list.)
Collapse
Posted by Andrei Popov on
nice, albeit does not work in Opera, at least on the bboard page.
Collapse
Posted by David Kuczek on
I suppose that if it doesn't work on the bboard it shouldn't work anywhere else on Opera... I am not sure what part of the code must be changed to make it Opera compliant, but you could recognize the browser with a js-sniffer and then automatically exchange that part of the code.
Doesn't seem to work on netscape 4.77 on the MAC