Symantec IGA

 View Only
  • 1.  Javascript set value of dropdown

    Posted Jan 18, 2024 04:44 AM

    Hi Community, 

    I'm trying to set or select the value of a dropdown list based on the value of another field.
    I tried this code on the validation but with no result. Y being the dropdown field.

    function validate(FieldContext, attributeValue, changedValue, errorMessage) {
       if (attributeValue == "X") {
        FieldContext.setFieldValue("Y", "value");

    Thanks already for your help,



  • 2.  RE: Javascript set value of dropdown

    Broadcom Employee
    Posted Jan 19, 2024 09:22 AM

    Let me know if this works for you.  Drop down code included just for better clarity with the function.

    <label for="dropdown">Select a value:</label>
      <select id="dropdown" onchange="setValue()">
        <option value="option1">Option 1</option>
        <option value="option2">Option 2</option>
        <option value="option3">Option 3</option>
      </select>
    
      <input type="text" id="result" readonly>
    
      <script>
        function setValue() {
          // Get the selected value from the dropdown
          var selectedValue = document.getElementById("dropdown").value;
    
          // Set the value to the input field
          document.getElementById("result").value = selectedValue;
        }
      </script>