好的,所以我正在做一個表單驗證在這個JS中一切都很好,但是現在我在輸出中遇到問題,我試圖顯示所有選擇的數據。所以我用了action屬性,並稱爲以下功能:功能不起作用
function funcs()
{
var favor = document.reg.favor[selectedIndex].value; //Select input
var fname = document.reg.fname.value; // text input
var lname = document.reg.lname.value; // text input
var email = document.reg.email.value; // text input
var pass = document.password.value; //text input
for(i=0;i<document.reg.rad.length;i++)
{
if(document.reg.rad[i].checked == true)
{
var rad = document.reg.rad[i].value; // Radio input
}
}
if(document.reg.bike.checked == true)
{
var bike = document.reg.bike.value; //CheckBox input
}
if(document.reg.car.checked == true)
{
var car = document.reg.car.value; //CheckBox input
}
document.write('<head><link type="text/css" rel="stylesheet" href="registrationtable.css"/></head><body>');
document.write("<div class = 'team'>");
document.write('<table>');
document.write("<tr><td> שם פרטי: </td><td>" + fname + "</td></tr> <tr><td> שם משפחה: " + lname + "</td></tr> <tr><td> אימייל: " + email + "</td></tr> <tr><td> סיסמא: " +pass +"</td></tr>");
document.write("<tr><td> השחקן האהוב עליך הוא " + favor +"</td></tr>");
document.write("</table>");
document.write("</div></body>");
}
這裏的表格標題:
<form name ="reg" action ="Javascript:funcs()" onsubmit ="return checkValidation()">
我想明確指出,所有的JavaScript代碼可以正常使用,另外,它必須是這個功能的東西。 當我按下發送按鈕時,它不會執行任何操作。任何人都知道最新的問題? 謝謝先進。
是否確定checkValidation返回true? – aquinas 2012-03-22 18:44:30
首先,你的代碼片段中沒有'checkValidation'函數。無法從不存在的函數返回值... – 2012-03-22 18:45:12
Marc B我假設'checkValidation()'是「所有其他正在工作的javascript代碼完美」並且'funcs'是函數不。我可能是錯的。 – 2012-03-22 18:49:44