【发布时间】:2016-10-23 21:02:12
【问题描述】:
我正在尝试制作一个简单的 web 应用程序。 我想将主页中的数据放入另一个窗口/选项卡上的输入框,但是当我打开它时输入框总是空的。
代码如下: global.js
function showUserInfo(event) {
// Prevent Link from Firing
event.preventDefault();
var _id = $(this).attr('rel');
var arrayPosition = userListData.map(function(arrayItem) { return arrayItem._id; }).indexOf(_id);
// Get our User Object
var thisUserObject = userListData[arrayPosition];
window.open('http://localhost:3000/editrecord', 'window', 'width=500,height=400');
var fName = thisUserObject.cName
$("#inputecName").attr('value', fname);
运行它会打开“editrecord”窗口,我试图获取的数据应该在“editrecord”页面的输入框中。
editrecord.jade
#editBox
fieldset
input#inputecName(type='text', placeholder='Customer Name', width = '50%')
br
button#btnEditRec(type='submit') Update Record
提前谢谢你。
【问题讨论】:
-
在OP中显示相关代码
-
你的应用是静态的还是动态的?
-
对不起,我不小心按了回车键。 :P
-
您在当前页面调用
$("#inputecName").attr('value', fname);,虽然$#inputecName似乎在新打开的window?还有,为什么把新开的window命名为"window"? -
将
$("#inputecName").attr('value', fname);更改为$("#inputecName").val(fname);- 使用val()
标签: javascript jquery node.js pug