以下代码生成带有单个输入框的提示,但是我需要有两个输入框。这可以实现吗?
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");
答案 0 :(得分: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>