• Resolved Sebalos

    (@sebalos)


    Hello,

    If I have 3 or 4 dropdown list I want when the user select in the first dopdown list a value to automatically set the same value in the other dorpdown lists. Also I want to let the user to change (if he want) the values from the other lists. I use some cod in one calculation field `(function(){
    var indexList = fieldname173;
    jQuery(‘.listC select’)[0].selectedIndex = indexList ;

    })()`
    but when I checked the values I saw that even the list have been changed the value from that changed list it is not ok.

    How can I do this ?

    Thank you very much !

    https://wordpress.org/plugins/calculated-fields-form/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    Please, tries the following solution:

    Assign a class name to the fieldname173 field, for example: listA, and then modifies the equation like follow:

    (function(){
    var tmp = fieldname173;
    jQuery('.listC select')[0].selectedIndex = jQuery('.listA select')[0].selectedIndex;
    })()

    The first line in the equation: var tmp = fieldname173; is a trick to evaluate the equation each time the user selects a different option in the fieldname173 field.

    Best regards.

    Thread Starter Sebalos

    (@sebalos)

    Thanks but it dose not work. When I change value from dropdown list A, the value in dropdown list C is changed also but when I checked the values in listC I saw that even the list have been changed the value remain the same. If I go manually and change values from dopdown C the value is ok.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    I don’t understand exactly what to you want, but I guess you are referring to the values in the calculated fields, after modify the selected index in the list C. You simply should throw an onchange event after select a different index in the list C, as follows:

    (function(){
    var tmp = fieldname173;
    jQuery('.listC select')[0].selectedIndex = jQuery('.listA select')[0].selectedIndex;
    jQuery('.listC select').change();
    })()

    Best regards.

    Thread Starter Sebalos

    (@sebalos)

    I have a dropdown listA with values 0, 1, 2 and dropdown listC with same values. I have also a calculation field that show me value from listC. When I change listA to 1, automatically listC has been changed to the same value but calculation field still show me 0 for listC. If I click on listC and chang manually value is ok, calculation field show me the real value.

    Thank again for your support !

    Plugin Author codepeople

    (@codepeople)

    Hi,

    With the last version of the equation I sent you, the calculated field associated to the listC should be modified too. Could you send me the link to your page to check the form in action, please?

    Best regards.

    Thread Starter Sebalos

    (@sebalos)

    It’s now working, thanks a lot 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Two or more dropdown with the same values’ is closed to new replies.