我'我试图在形式窗口中将我的注册按钮放在模式窗口中,该窗口将显示用户信息的输入。到目前为止我有3个问题。
到目前为止我的代码:
HTML - 表格:
<div id="myForm">
<form name="myForm" method="POST">
<fieldset>
<legend>Register your interest</legend>
<div id="divpopup">
<p><label class="title" for="name">Your name:</label>
<input type="text" name="name" id="name"><br />
<label class="title" for="email">Your email:</label>
<input type="text" name="email" id="email"></p>
<label class="title" for="persons">Persons:</label>
<input id="personsId" type="text" name="persons" id="persons"></p>
<p><label for="location" class="title">Your closest center:</label>
<select class="target" name="location" id="location">
<option value="ny">New York</option>
<option value="il">Chicago</option>
<option value="ca">San Francisco</option>
</select></p>
<span class="title">Are you a member?</span>
<label><input type="radio" name="member" value="yes" /> Yes</label>
<label><input type="radio" name="member" value="no" /> No</label></p>
</div>
</fieldset>
<div class="submit" id="myButton"><input type="button" id="btnclick" value="Register" /></div>
</form>
<div class="quantity"></div>
</div>
SCRIPT - 模态窗口:
<script type="text/javascript"> //register modal window
$(function() {
$("#btnclick").click(function() {
$("#divpopup").dialog({
title: "Your Input",
width: 500,
height: 500,
modal: true,
buttons: {
Close:
function() {
$(this).dialog('close');
}
}
});
});
})
</script>
答案 0 :(得分:1)
您要做的是将表单克隆到对话框中。确认后,重置原始表单。像这样:
$("#btnclick").click(function() {
var dial = $("#myForm").clone();
dial.dialog({
modal: true,
draggable: false,
resizable: false,
position: ['center', 'top'],
show: 'blind',
hide: 'blind',
width: 400,
dialogClass: 'ui-dialog-osx',
buttons: {
"Confirm": function() {
$("#myForm").find("input").val("");
$(this).dialog("close");
}
}
});
});