Multiple input boxes - alertifyjs / Jquery

前端 未结 1 684
Happy的楠姐
Happy的楠姐 2021-01-25 01:21

I am trying to create a prompt dialog box using alertifyjs that has multiple input boxes. I have managed to create the dialog box to show the multiple boxes but I cant seem to m

相关标签:
1条回答
  • 2021-01-25 02:17

    In your script you call a function named updateListItems(inpOneVal,inpTwoVal);

    As that function is not declared anywhere, it errors, so with that temporarily commented out, it works.

    Stack snippet

    <html>
    
    <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/css/alertify.min.css" />
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/css/themes/bootstrap.min.css" />
      <script src="https://cdn.jsdelivr.net/npm/alertifyjs@1.11.1/build/alertify.min.js"></script>
    
    </head>
    
    <body>
    
      <div style="display:none;">
        <div id="dlgContent">
          <p> Enter Value One </p>
          <input class="ajs-input" id="inpOne" type="text" value="Input One Default Value" />
    
          <p> Enter Value Two </p>
          <input class="ajs-input" id="inpTwo" type="text" value="Input two default Value" />
    
        </div>
      </div>
    
      <!-- the script  -->
    
      <script>
        var dlgContentHTML = $('#dlgContent').html();
    
        $('#dlgContent').html("");
        alertify.confirm(dlgContentHTML).set('onok', function(closeevent, value) {
          var inpOneVal = $('#inpOne').val();
          var inpTwoVal = $('#inpTwo').val();
          //updateListItems(inpOneVal,inpTwoVal);	
    
          if (inpOneVal == "test" && inpTwoVal == "test") {
            alertify.success('Successful');
          } else {
            alertify.error('Wrong')
    
          }
        }).set('title', "Update");
      </script>
    
    </body>
    
    </html>

    0 讨论(0)
提交回复
热议问题