gpt4 book ai didi

javascript - Alertify Prompt - 允许用户输入值并提交表单

转载 作者:行者123 更新时间:2023-12-01 01:43:45 28 4
gpt4 key购买 nike

使用alertify - 版本0.3.11,我能够获取用户输入详细信息并能够在提示对话框中显示它。但我有多种值(value)观。用户输入、下拉值、日期选择等

var totalResources = jQuery('#grid').jqGrid('getGridParam', 'selarrrow');

//set custom button title for Form Submit
alertify.set({ labels: {
ok : "Submit Data",
cancel : "Cancel"
} });


//fetch user input comment
alertify.prompt("Please enter note/remarks for this Form :<br/>Total Resource(s): <strong>"+totalResources.length+"</strong>", function (e,value) {


if (e) {
alertify.success("Data has been submitted");

//encodes special characters remarks
var sow = encodeURIComponent(value);

$.post(SITE_URL+"somecontroller/someaction",$("#frm_submit").serialize()+ "&resource_ids="+resource_ids+"&sow="+sow, function( data ) {
});


}else{
alertify.error("Your Data is not submitted");
}
});

类似下图所示

enter image description here

我如何使用alertify构建一个模式表单,用户将看到预先获取的详细信息并可以输入他的详细信息并提交?

最佳答案

他们在 Alertify 中添加了表单功能。看看this

他们的网站代码如下:-

<!-- the form to be viewed as dialog-->
<form id="loginForm">
<fieldset>
<label> Username </label>
<input type="text" value="Mohammad"/>

<label> Password </label>
<input type="password" value="password"/>

<input type="submit" value="Login"/>
</fieldset>
</form>

和 JS 代码:-

alertify.genericDialog || alertify.dialog('genericDialog',function(){
return {
main:function(content){
this.setContent(content);
},
setup:function(){
return {
focus:{
element:function(){
return this.elements.body.querySelector(this.get('selector'));
},
select:true
},
options:{
basic:true,
maximizable:false,
resizable:false,
padding:false
}
};
},
settings:{
selector:undefined
}
};
});
//force focusing password box
alertify.genericDialog ($('#loginForm')[0]).set('selector', 'input[type="password"]');

关于javascript - Alertify Prompt - 允许用户输入值并提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31780423/

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