gpt4 book ai didi

javascript - AlertifyJS 提示对话框中的多个输入框

转载 作者:行者123 更新时间:2023-11-29 14:47:40 25 4
gpt4 key购买 nike

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

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");

最佳答案

所以我能够通过以下代码实现这一点:

<!-- 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>

关于javascript - AlertifyJS 提示对话框中的多个输入框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30712759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com