目前,我被要求使用ASP.NET MVC构建表单,其中要求是:
以下是一些图片来说明我的需求:
预期观点: Image 1
这是我的代码
//Centering the popup window, Code from https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
function popUp(url, title, w, h) {
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
}
<form method="post">
<div>
Name:
<input type="text" name="textName" id="txt" value="" />
</div>
<div>
Gender:
<input type="radio" name="gender" value="female" /> Male
<input type="radio" name="gender" value="male" /> Female
</div>
<div>
DOB:
<input type="date" name="tanggal" id="txtDate" />
</div>
<div id="divSubmit">
<input type="submit" value="View" id="submit" onclick="popUp('Index.html','Index','900','500'); return false;" />
</div>
</form>
这是以上代码的结果视图:
结果视图:Image 2
非常感谢任何建议和帮助!
答案 0 :(得分:1)
您可以在window.open之后添加此代码。
newWindow.onload = function () {
this.document.getElementById('txtPopup').value = document.getElementById('txt').value;
}
替换txtPopup,你必须输入弹出窗口输入的id。