Bob, in v3 I have some forms with JS in it
Basically it does the following
When EG)select_2 == Ja, a field will appear in the form.
On "Nee" the field does not show
So...how to set this up in V4??
This the old code
Basically it does the following
When EG)select_2 == Ja, a field will appear in the form.
On "Nee" the field does not show
So...how to set this up in V4??
This the old code
<?
$doc =& JFactory::getDocument();
$script = "window.addEvent('domready', function() {
$('select_2').addEvent('change', function(event) {
var e = new Event(event);
if (e.target.value == 'Ja') {
$('Voornaam').getParent().getParent().setStyle('display', 'block');
} else {
$('Voornaam').getParent().getParent().setStyle('display', 'none');
}
});
});";
$doc->addScriptDeclaration($script);
?>
Hi SPABO,
Drag a Load JS action itno the OnLoad event, move it up before the Show HTML action and add the script there:
Bob
Drag a Load JS action itno the OnLoad event, move it up before the Show HTML action and add the script there:
window.addEvent('domready', function() {
$('select_2').addEvent('change', function(event) {
var e = new Event(event);
if (e.target.value == 'Ja') {
$('Voornaam').getParent().getParent().setStyle('display', 'block');
} else {
$('Voornaam').getParent().getParent().setStyle('display', 'none');
}
});
});Check that the input ids match up.Bob
I did Bob...but than website does not load completely as well
I have this in now (with php-tags)
Here the code of the Field, but I recaal "something had to be added?
I have this in now (with php-tags)
<?
window.addEvent('domready', function() {
$('intro2).addEvent('change', function(event) {
var e = new Event(event);
if (e.target.value == 'Ja') {
$('Intro').getParent().getParent().setStyle('display', 'block');
} else {
$('Intro').getParent().getParent().setStyle('display', 'none');
}
});
});
?>Here the code of the Field, but I recaal "something had to be added?
<div class="ccms_form_element cfdiv_text" id="intro_container_div"><label for="Intro">Naam intr</label><input id="Intro" maxlength="150" size="30" class="" title="" type="text" value="" name="Intro" />
<div class="clear"></div><div id="error-message-Intro"></div></div>
Hi SPABO,
This is JavaScript and doesn't need the 'php' tags. They may be what is breaking your page.
Bob
This is JavaScript and doesn't need the 'php' tags. They may be what is breaking your page.
Bob
Hi SPABO,
This line is missing a ' after intro2:
When that's fixed selecting Nee hides the whole form which probably isn't' what you want.
Bob
This line is missing a ' after intro2:
$('intro2).addEvent('change', function(event) {When that's fixed selecting Nee hides the whole form which probably isn't' what you want.
Bob
I have added the "'" now , website behaves now normal.
Indeed, it's not what I wish
If "Ja" is selected, Field Name "Intro" should appear, if "Nee" has been selected, this field shoold still be hidden
Indeed, it's not what I wish
If "Ja" is selected, Field Name "Intro" should appear, if "Nee" has been selected, this field shoold still be hidden
Hi SPABO,
Then these lines are wrong
Bob
Then these lines are wrong
$('Intro').getParent().getParent().setStyle('display', 'block');maybe just one getParent, or better check the id for the Intro code block and use that.Bob
Hi Bob
A combination...
On the form code ( custommode) this is the field (added class display,none)
and using your code
This was the tric
By the way, the select is set standard on "Nee" , otherwise, it disappears only when Nee is selected
A combination...
On the form code ( custommode) this is the field (added class display,none)
<div class="ccms_form_element cfdiv_text" style="display: none" id="intro_container_div">and using your code
$('Intro').getParent().setStyle('display', 'block');This was the tric
By the way, the select is set standard on "Nee" , otherwise, it disappears only when Nee is selected
This topic is locked and no more replies can be posted.
