Jump to content
  • 0

disabled/disregard values


Gigigigi
 Share

Question

Hi! I have a 3 text fields and 2 of them are set to radio buttons and 1 is used for criteria. 

If 1st radio button = Yes then the 2nd radio button will show with 3 options as well as the field for the criteria. There are 3 criteria that are set to dropdown. 

When the user selects an option from the 2nd radio button, the dropdown will appear depending on the selection and what I would like to achieve is, for example, the user selects 'Approved' option from the 2nd radio button and the dropdown appears and they select 'A' value and they decide to revert it back or choose the second option 'Disapproved 'from the radio button and chooses '2nd' for the value, the values selected from the dropdown of the first option 'Approved' should disregard or disabled.

 

image.png.22bff1020c2c790a255e542f1020fb0a.pngimage.png.c1d0caac650eeafa21443393a1fe04cf.png

 

Any suggestion would be appreciated!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @Gigigigi - Just to confirm, for every change in the 2nd radio button - you would like your 2nd or 3rd dropdown to be blank or back to its first option(which is no value), is that correct? If yes, you may try to use this custom JS:

<script>

document.querySelector("input[id*='SPECIFIC_ID_OF_YOUR_RADIOBUTTON']").addEventListener("change", function test(){

//checks if there are two or more options already
if(document.querySelector("select[name='SPECIFIC_NAME_OF_YOUR_DROPDOWN']").options.length >= 2){

//selects 1st value in the dropdown, count starts from [0]
document.querySelector("select[name='SPECIFIC_NAME_OF_YOUR_DROPDOWN']").options[0].selected=true;
}

});

</script>

make sure to check the Form Elements  of your DataPage here: 

If you want to have additional condition to other radio buttons, you just need to copy both scripts:

<script>

//Any Radio Button
document.querySelector("input[id*='SPECIFIC_ID_OF_YOUR_RADIOBUTTON']").addEventListener("change", function test(){

//checks if there are two or more options already
if(document.querySelector("select[name='SPECIFIC_NAME_OF_YOUR_DROPDOWN']").options.length >= 2){

//selects 1st value in the dropdown, count starts from [0]
document.querySelector("select[name='SPECIFIC_NAME_OF_YOUR_DROPDOWN']").options[0].selected=true;
}

});
  
//Approved Radio Button
document.querySelector("input[id*='SPECIFIC_ID_OF_YOUR_RADIOBUTTON']").addEventListener("change", function test(){

//checks if there are two or more options already
if(document.querySelector("select[name='SPECIFIC_NAME_OF_YOUR_DROPDOWN']").options.length >= 2){

//selects 1st value in the dropdown, count starts from [0]
document.querySelector("select[name='SPECIFIC_NAME_OF_YOUR_DROPDOWN']").options[0].selected=true;
}

});

</script>

Hope it helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...