3

以下代码使用单个输入框生成提示,但是我需要有两个输入框。这是可以实现的吗?

alertify.prompt("Please enter Values","Default Text").set('onok', function(closeevent, value) { 
if (value == "" || value == " " )
{
    alertify.error("No value entered");
    return;
}
else
{
    updateItem(selectedItem,value);
}
}).set('title',"Update Values");

4

1 回答 1

2

所以我能够使用以下代码实现这一点:

<!-- the content to be viewed as dialog
  ***Define the two input boxes
  *** Note the input element class "ajs-input" that i have used here , this is the class used by AlertifyJS for its Input elements.
-->
<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(""); 
/* This is important : strip the HTML of dlgContent to ensure no conflict of IDs for input boxes arrises" */


/* Now instead of making a prompt Dialog , use a Confirm Dialog */


alertify.confirm(dlgContentHTML).set('onok', function(closeevent, value) { 
					var inpOneVal = $('#inpOne').val();
					var inpTwoVal = $('#inpTwo').val();
					/* Insert your code to work with the two values */ 				
				}).set('title',"Update");
 </script>

于 2015-06-08T17:42:56.477 回答