我想在HTML表单下方的同一页面中打印提交的输入元素。选中的复选框元素应全部打印。图像元素可以避免。HTML页面内的输出表格
该功能似乎没有工作。
function validateForm(myForm) {
var a = document.getElementById("fname").value;
document.getElementById("display").innerHTML = y;
var b = document.getElementByName("passwords").value;
document.getElementById("display1").innerHTML = y;
var c = document.getElementByName("gender");
var i;
for (i = 0; i < c.length; ++i) {
if (c[i].checked)
document.getElementById("display1").innerHTML = c[i].value; //looping through radio buttons
}
var d = document.getElementByName("hobbies");
for (i = 0; i < d.length; ++i) {
if (d[i] checked)
ans = ans + d[i].value; //looping through checkboxes and adding to display in display 2 id.
}
document.getElementById("display2").innerHTML = ans;
var e = document.getElementByName("cities").value;
document.getElementById("display3").innerHTML = e;
}
Personal Details
Name:
Password:
Gender:
Male
Female
Hobbies:
Reading
Writing
City:
Surat
Ahmedabad
Rajkot
Vadodra
Image:
+2
它应该是'getElementsByName'? –