问题
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 selected will store that selection in some global variable in PHP.
Really don't have idea on how to? Tried jquery etc but no relevant info.
Thanks in advance.
回答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:
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
It results in something like this:
You can add any HTML inside, including dropdown menus.
来源:https://stackoverflow.com/questions/27540706/how-to-create-java-script-prompt-with-dropdown