Forums

Textfield depending on dropdown value

PeteS 10 Oct, 2015
Hello!
I am new to ChronoForms and I read a lot of posts here... Thanks in advance for your good work!

Using:
Joomla! 3.4.4
ChronoForms V5

I came across a code here in the forums:

window.addEvent('domready', function() {
      var select, other;
      select = $('urlerror_drop');
      other  = $('urlerror_answer');
      switchOther();
      select.addEvent('change', switchOther);

      function switchOther() {
        if ( select.value == 'Ja' ) {
          other.disabled = false;
        } else {
          other.value = '';
          other.disabled = true;
        }
      }
    });


Which I was planning to use it for liberating a textfield (urlerror_answer) if the value of the dropdown (urlerror_drop) list would be "Ja".

My settings are as follows:
Dropdown list: http://prntscr.com/8pp60v
Textfield: http://prntscr.com/8pp68i
Both have "Required: Yes"

Setup: http://prntscr.com/8pp6tu

Unfortunately it does not work😟

I read about a built-in event manager in V5 (https://www.chronoengine.com/forums/posts/t99165/p344913/combo-the-checkbox.html#p344913) but did not found any documentation about this function.

I would appreciate a little help or just links to some comprehensive documentation.
Thanks!
GreyHead 11 Oct, 2015
Hi PeteS,

The JavaScript that you found was for ChronoForms v4 and used the MooTools library which Joomla! have now dropped - they are using jQuery instead :-(

Please go to your drop down settings and click the Events tab.

Click the green Add New Event button so that you have two events

Configure the first one as On : = : Ja : Show Parent : urlerror_answer : / empty/
And the second one as On : != : Ja : HideParent : urlerror_answer : / empty/

Make sure that the Text box element has got the id and name set to urlerror_answer

That should do it.

Bob
PeteS 13 Oct, 2015
Hello GreyHead,

Thank you for pointing me in the right direction, unfortunately it does not work as it should, to be honest, it doesn't work at all.

Please find my settings as follows:
Dropdown element Event Tab: http://prntscr.com/8qzgak
I used the name / ID you suggested (urlerror_answer) on the text field: http://prntscr.com/8qzidp

I as well tried the same thing with the ID number of the text field, which would be Nr. 2: http://prntscr.com/8qzj1c

At the setup actually nothing changed, only that I deleted the depreciated MooTools code: http://prntscr.com/8qzjyv

Now I would like to buy a subscription, but it seems difficult for me to decide which one would be the best. Please advise me on this matter, as I really like the Chronoform and would be happy to help in some way.

Thanks for your appreciated feedback!
PeteS 13 Oct, 2015
I tried again, this time with another form, which I created especially to check this functionality.

It seems that the script does not run correctly, as the field is hidden but on change from No to Yes it does not show up.

Please find a sample here:
http://www.lehrmittelperlen.net/index.php?option=com_chronoforms5&chronoform=dropdowndependings

It's just a simple demo with two fields:
imgur.com/KWZl261.jpg

on the dropdown element I have
imgur.com/V5pOilY.jpg

I looked for any js conflicts but could not find anything special.😟
GreyHead 14 Oct, 2015
Hi PeteS,

The Event code works on the Value of the drop-down option (what is sent when the form is submitted) and not on the Text which is displayed in the drop-down on the form. You have
<select name="dropdown1" id="dropdown1" . . .>
<option value="0">Ja</option>
<option value="1">Nein</option>
</select>
So the values are 0 and 1

You could use these in the Events tab but it's probably better here to change the options to match the Text e.g.
Ja=Ja
Nein=Nein
Note that these are case sensitive so the value Ja is not the same as ja (which you have in the Events settings in one of the images).

Bob
PeteS 15 Oct, 2015
Kudos GreyHead!

Sure thing, I was absolutely blind.

It works and I would like to repeat my question...
"Now I would like to buy a subscription, but it seems difficult for me to decide which one would be the best. Please advise me on this matter, as I really like the Chronoform and would be happy to help in some way"

I really find it hard to understand which subscription would be suitable for me.
PeteS 15 Oct, 2015
oh...

I just found out that the depending text field, also set to "Required: Yes", will not be checked when the drop down menu is set to "No". Like this the function is somehow less useful as I would like to have the user choose explicitly "Ja" and then fill in the text field for being able to send the form.

Is there any way around this?
GreyHead 16 Oct, 2015
Hi PeteS,

You really don't want to make invisible inputs required - that does make it difficult for the user.

You can add Custom Code that will disable the submit button unless Ja is selected in the DropDown.

Bob
This topic is locked and no more replies can be posted.