任何人都可以告訴我爲什麼下面的JavaScript函數沒有調用時點擊按鈕或提交表單。Javascript函數不叫onclick()和onsubmit()
我不明白這是這個代碼的錯誤。請幫助
<script type="text/javascript">
function confrm()
{
\t alert("check1");
\t if(confirm("Are you going to submit this form?")==true)
\t {
\t \t return true;
\t }
\t else
\t {
\t \t return false;
\t }
}
function checkfrm()
{
\t var selcteddate=document.newrequest.sel.value;
\t var sdate=new Date(selcteddate);
alert("check 2");
\t if(document.newrequest.server.value=="select")
\t {
\t \t alert("Select server");
\t \t return false;
\t }
\t else
\t {
\t \t return true;
\t }
}
</script>
<form id="newrequest" name="newrequest" method=post action="cgi-bin/newrequest.cgi" onsubmit="return checkfrm();">
<td colspan=2>
<input type="submit" id="submit" name="submit" value="Submit" onclick="return confrm();" />
</td>
你有沒有真正嘗試自己的代碼片段提交指南?這對我來說可以。 – JJJ 2015-02-11 08:45:16
如果它在「真實」代碼中不適用於您,請打開瀏覽器的錯誤控制檯。很可能是您的代碼中有可能停止腳本執行的其他地方出現語法錯誤。 – JJJ 2015-02-11 08:45:54
代碼段也適用於我 – donnywals 2015-02-11 08:46:17