php兩種按鍵處理事件

初學PHP,菜鳥一個,記錄下學習過程遇到的問題..

點擊按鈕事件處理辦法

一個form表單裏兩個按鈕,一個處理form中的action事件,另一個則處理另珍上php事件

1.事例代碼:

<html>
<head>
<meta http-equiv="Content-Type"content="text/html; charset=utf-8">
<script type="text/javascript">
functionaaa()
{
document.form.action="page2.php";
}
</script>
</head>
<body>
<form name="form"method="post"action="page1.php">
<input type="text"name="name"/>
<input type="submit"name="check"value="驗證碼"onclick=="aaa()"/>
<input type="submit"name="submit"value="註冊"/>
</form>
</body>
</html>

2.事例代碼

<html>
<head>
<meta http-equiv="Content-Type"content="text/html; charset=utf-8">
</head>
<body>
<form name="form"method="post"action="page1.php">
<input type="text"name="name"/>
<input type="submit"name="check"value="驗證碼"onclick="javascript:this.form.action='page2.php';this.form.submit();"/>
<input type="submit"name="submit"value="註冊"/>
</form>
</body>
</html>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章