Is there any way to create prompt with two input fields?

后端 未结 4 2014
名媛妹妹
名媛妹妹 2020-12-06 08:45

Is there any way to create prompt in JavaScript with two input fields ?

I tried that code, but it didn\'t help me :

var a = prompt(\"A : \", \"\");         


        
相关标签:
4条回答
  • 2020-12-06 09:25

    Short of constructing your own using DOM methods and Input elements: No.

    0 讨论(0)
  • 2020-12-06 09:33

    This is not possible with an OS or native browser window popping up. You will have to create a custom overlay dialog.

    I would advise using a library like jQuery UI to do this. You can then customize whatever is in the popup.

    You can view a demo of the dialog here

    0 讨论(0)
  • 2020-12-06 09:40

    JavaScript Code

               <script>
                 $( "#create-user" )
                 .button()
                 .click(function() {
                 $( "#dialog-form" ).dialog( "open" );
                   });
                });
               </script>
    

    Html Code:

              <div id="dialog-form" title="Create new user">
              <p class="validateTips">All form fields are required.</p>
              <form>
             <fieldset>
             <label for="name">Name</label>
              <input type="text" name="name" id="name" class="text">
              <label for="email">Email</label>
             <input type="text" name="email" id="email" value="" class="text">
             <label for="password">Password</label>
              <input type="password" name="password" id="password" value="" class="text">
            </fieldset>
            </form>
           </div>  
    
          <button id="create-user">Create new user</button>
    
    0 讨论(0)
  • 2020-12-06 09:40
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>dialogo</title>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    </head>
    <body>
    <script>
    function abrete(){
    $("#dialog" ).dialog();
    }
    </script>
    <div id="dialog" title="Create new user" style="display:none;">
    <p class="validateTips">All form fields are required.</p>
    <form action='tuscript.php'>
    <fieldset>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="text">
    <label for="email">Email</label>
    <input type="text" name="email" id="email" value="" class="text">
    <label for="password">Password</label>
    <input type="password" name="password" id="password" value="" class="text">
    </fieldset>
    </form>
    </div>
    <button onclick='abrete()'>Create new user</button>
    </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题