Skip to content Skip to sidebar Skip to footer

How To Create Java Script Prompt With Dropdown

I am new to coding in web technology. To my surprise got to know that we can have prompt only with text. My requirement is to have prompt with options(dropdown) list which when sel

Solution 1:

Instead of a standard JavaScript prompt, you can use something like Modals from Bootstrap or Dialogs from jQuery UI.

See this demo for some idea on how those modals can look like and behave.

This is how you define the modals - example from the Bootstrap page:

<divclass="modal fade"><divclass="modal-dialog"><divclass="modal-content"><divclass="modal-header"><buttontype="button"class="close"data-dismiss="modal"><spanaria-hidden="true">&times;</span><spanclass="sr-only">Close</span></button><h4class="modal-title">Modal title</h4></div><divclass="modal-body"><p>One fine body&hellip;</p></div><divclass="modal-footer"><buttontype="button"class="btn btn-default"data-dismiss="modal">Close</button><buttontype="button"class="btn btn-primary">Save changes</button></div></div><!-- /.modal-content --></div><!-- /.modal-dialog --></div><!-- /.modal -->

It results in something like this:

enter image description here You can add any HTML inside, including dropdown menus.

Post a Comment for "How To Create Java Script Prompt With Dropdown"