Forums

set textbox with dropdown events inside multiplier

yusufo 27 May, 2016
Hi,

I have a form with a multiplier container and inside it a multifield with 4 elements.

The first element is a dropdown field (fila[__N__][tipo]) and the last one a textbox (fila[__N__][horas]).

I want to assign the number 8 in textbox if the dropdown value is "Vacaciones".

You can see on the image attached, how is configured the dropdown.

The code added to Load Javascript action is:

function setHoras() {
    $('#horas__N__').val(8);
}
yusufo 27 May, 2016
I forgot to upload the image.
GreyHead 27 May, 2016
Hi yusufo,

It is not straightforward to use Javascript with Multiplier elements - it is possible though I don't think you can use the built-in events.

The main problem you have is that the __N__ will have been replaced by the time this code is run so nothing happens. If you look at your multiplier HTML you will see the IDs are like horas1, horas2, . . . so your script has to recognise the current value of N and then apply that.

Please see this FAQ for an example of using JavaScript with a Multiplier.

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