简体   繁体   English

如何将某些HTML从一个页面转换为另一页面的表单?

[英]How can I get certain HTML from one page into a form onto another?

I've got a work calculator on a website I'm developing. 我正在开发的网站上有一个工作计算器。 After a person gathers the works he needs, how can I make it so when they click a button they are redirected to the contact us page and the works they've calculated are inserted into a text box? 当一个人收集了他需要的作品后,我该如何做,以便当他们单击按钮时将他们重定向到“联系我们”页面,并将他们计算出的作品插入文本框中?

Some more information: 更多信息:

In the calculator, the initial works are displayed in a table through the use of a Javascript script, like so: 在计算器中,最初的作品通过使用Javascript脚本显示在表格中,如下所示:

for(var i=0; i < cartArray.length; i++){
    var cartRow = $("<tr>", {
        html:'<td class="itemname">'+cartArray[i][1]+'</td><td><input class="quantity" name="'+cartArray[i][0]+'" type="text" size="2" value="'+cartArray[i][3]+'"/></td><td><a href="#'+cartArray[i][0]+'">Remove</a></td>'
    });
    cartTable.append(cartRow);
    totalCost += (cartArray[i][2] * cartArray[i][3]);
}

I only need the item name, quantity and total to be inserted into the textbox. 我只需要将商品名称,数量和总计插入文本框即可。 How would I do this? 我该怎么做?

I would suggest you to use window.opener to refer to another page if both pages are in same domain. 如果两个页面都在同一个域中,我建议您使用window.opener来引用另一个页面。 For example: document.getElementById("textfield1").value = window.opener.document.getElementById("textfield2").value; 例如:document.getElementById(“ textfield1”)。value = window.opener.document.getElementById(“ textfield2”)。value;

Learn more about window.opener in https://developer.mozilla.org/en/DOM/window.opener https://developer.mozilla.org/en/DOM/window.opener中了解有关window.opener的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM