How to create java script prompt with dropdown [closed]

泪湿孤枕 提交于 2021-02-04 07:47:38

问题


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">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>One fine body&hellip;</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:

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



来源:https://stackoverflow.com/questions/27540706/how-to-create-java-script-prompt-with-dropdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!