Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 输入的数据摘要_Javascript_Html - Fatal编程技术网

Javascript 输入的数据摘要

Javascript 输入的数据摘要,javascript,html,Javascript,Html,我想要一个摘要页 例如,在第1页中,我将询问客户姓名、电子邮件、订单,如html所示 单击提交后,它会将我链接到第2页,在那里会弹出一个窗口,总结如下 Customer name: xxxxxxx Email: xxxxxxx No of quantity ordered for item A:xx No of quantity ordered for item B:xx No of quantity ordered for item C:xx Total cost:xx HTML: 我认为这

我想要一个摘要页

例如,在第1页中,我将询问客户姓名、电子邮件、订单,如html所示

单击提交后,它会将我链接到第2页,在那里会弹出一个窗口,总结如下

Customer name: xxxxxxx
Email: xxxxxxx
No of quantity ordered for item A:xx
No of quantity ordered for item B:xx
No of quantity ordered for item C:xx
Total cost:xx
HTML:


我认为这与法语、哈兹勒努特语和哥伦比亚语在代码中被视为字符串这一事实有关。在执行totalCost计算之前,请尝试对每个项目使用parseInt


如果您使用的是html 5,并且只使用较新的浏览器,您可能会使用input type=number而不是input type=text。为了捕获用户在主页上输入的数据并将其显示到第二页,您需要使用提交表单,然后在second.php中,您需要获取这些值并根据需要显示

为了使其工作,您必须在每个表单元素上使用'name'属性。例如:

<input type = "text"  size = "5"  id = "cost" name="cost" onfocus = "this.blur();" />

它计算并显示总成本。检查这一点是的。但是现在我如何从客户那里获取输入并弹出数据输入,包括我的问题中提到的项目+总成本?您是否注意到helpers[]数组只有3个元素?
 var helpers = ["Your name must be in the form: \n \
 first name, middle initial., last name",
"Your email address must have the form: \
user@domain",]

function messages(adviceNumber) {
document.getElementById("adviceBox").value = 
                              helpers[adviceNumber];
}
function computeCost() {
var french = document.getElementById("french").value;
var hazlenut = document.getElementById("hazlenut").value;
var columbian = document.getElementById("columbian").value;

document.getElementById("cost").value = 
totalCost = french * 3.49 + hazlenut * 3.95 + 
          columbian * 4.59;
}
<input type = "text"  size = "5"  id = "cost" name="cost" onfocus = "this.blur();" />