寫了一個頁面,在js里面呼叫submit();死活沒反應
有大佬知道為啥碼??吧type改成submit又可以,但我要先在js里面判斷,不能這樣做
<script type="text/javascript">
function test(){
var title = bbb.title.value;
var content = bbb.content.value;
if(title == ""||title == " "){
alert("請輸入標題");
return;
}
if(content == ""||conten == " "){
alert("請輸入正文內容");
return;
}
bbb.submit();
}
</script>
<body background="D:\程式檔案\189000148 郭思呈\郭思呈\GuoSiCheng_01_48\GuoSiCheng\WebContent\images\back.png">
<form action="sendnews_result.jsp" method="post" name="bbb">
<table border="0" cellspacing="5" cellpadding="0" width="25%" style="font-family:SimHei">
<tr>
<td>標題:</td>
<td><input id="title" type="text" size="30" name="title" style="border-radius:9px;width:200px;height:30px;" ></td>
</tr>
<tr>
<td>正文:</td>
<td><textarea rows="25" cols="100" name="content" style="border-radius:10px;"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<input class="button" type="button" value="https://bbs.csdn.net/topics/提交" onclick="test()">
<input class="button" type="reset" value="https://bbs.csdn.net/topics/重置" >
</td>
</tr>
</table>
</form>
</body>
跳轉的jsp和這個jsp都在一個檔案下的
uj5u.com熱心網友回復:
type=submit 是form默認的提交事件你要在test()方法中通過ajax向后臺提交你form的請求
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/51628.html
標籤:HTML(CSS)
上一篇:Angular非父子組件的呼叫
