首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AlertifyJS提示对话框中的多个输入框

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

Stack Overflow用户
提问于 2015-06-08 23:06:49
回答 1查看 2.7K关注 0票数 3

下面的代码产生了一个只有一个输入框的提示,但是我需要有两个输入框。这是可以实现的吗?

代码语言:javascript
复制
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");

EN

回答 1

Stack Overflow用户

发布于 2015-06-09 01:42:56

因此,我能够通过以下代码实现这一点:

代码语言:javascript
复制
<!-- 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>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30712759

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档