Skip to content
Advertisement

HTML form. How to enable button to close popup window after a valid dropdown selection is made

It should be really simple but I can’t figure it out, so any help would be gratefully received.

I have a very simple pop-up with a form dropdown with some disabled options and some valid options.

JavaScript

What I need to achieve is

  1. for the ‘Accept’ button to be disabled until a valid option is selected from the dropdown (values 12,13,14,15),

  2. once a valid selection is made and the button is enabled; to close the popup when the button is clicked.

No data is sent anywhere, I just need a user to make a selection and then close the popup.

TIA

Advertisement

Answer

I would do something like this: start with the disabled button and add an id to it, so it’s easier to intercept.

JavaScript

Then the jquery part, you could listen to the select change, grab it’s value, save it to a variable and enable the button if value is not empty

JavaScript

The menu will close automatically after you click outside of it, so no need to add code for that

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement