Forums

Show / Hide Content depending on Selection

TomX 16 May, 2011
Hi,

I have a simple form with a select box. I want to show / hide a textfield or something else depending on the selection.

I added a script but it does not work!?

CF v4 / Joomla 1.5 / MooTools Upgrade 1.2

The script:

window.addEvent('domready', function() {
 $('input_select_betreff').addEvent('change', function() { 
 if ($('input_select_betreff').value == 'hochzeitsfotografie' ) { 
 $('gew_nschte_leistung_container_div').setStyle('display', 'block'); 
 } else { 
 $('gew_nschte_leistung_container_div').setStyle('display', 'none'); 
 } 
 });
 // initialise the display
 if ($('input_select_betreff').value == 'hochzeitsfotografie' ) { 
 $('gew_nschte_leistung_container_div').setStyle('display', 'block'); 
 } else { 
 $('gew_nschte_leistung_container_div').setStyle('display', 'none'); 
 } 
});
Max_admin 19 May, 2011
Hi TomX,

The code looks ok to me, did you add it to a "load JS" code action in the "on load" event ? or did you use the "easy wizard" ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
TomX 19 May, 2011
I used the Form Wizard to create the form and edited it with the Wizard to insert the code in the Actions --> Load JS section.

Regards
Tom
TomX 28 May, 2011
Nothing?
GreyHead 28 May, 2011
Hi TomX,

Your code works OK here. Checked in FF & IE7, 8 & 9

I suspect that there may be a problem with the ü in Gewünschte Leistung - but I can't see where that is.

Bob
Max_admin 31 May, 2011
Hi TomX,

Apologies, I didn't check here the last week, did you try Bob's suggestion ? I think any special characters may not work well with the javascript code.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.