我目前的代碼:
<html>
<body>
<h1>Select button </h1>
<form method="get">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
Choose your page when submit:
<button name="subject" type="submit" value="aa">Page A</button>
<button name="subject" type="submit" value="bb">Page B</button>
</form>
</body>
</html>
我如何為流程制作代碼:單擊“頁面 A”按鈕重定向到“http://linkA”或單擊“頁面 B”按鈕重定向到“http://linkB”
謝謝
uj5u.com熱心網友回復:
你有很多選擇:
使用常規鏈接,并將其樣式設定為 CSS 中的按鈕
使用 Javascript: onclick="window.location='TARGET';"
將每個提交按鈕放在自己的表單中,并使用不同的操作引數
使用 formaction HTML 屬性(使用這個!)
<form method="get" action="pageA">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
Choose your page when submit:
<button name="subject" type="submit" value="aa">Page A</button>
<button name="subject" type="submit" value="bb" formaction="/pageB">Page B</button>
</form>
uj5u.com熱心網友回復:
您可以嘗試使用此自定義代碼
html代碼
<html>
<body>
<h1>Select button </h1>
<form method="get" id="form-one" action="">
<form method="get" id="form-two" action="" style="display:none">
<button name="subject" type="submit" id="button-one" value="aa">Page A</button>
<button name="subject" type="submit" id="button-two" value="bb">Page B</button>
</form>
</body>
</html>
Javascript代碼
$("#button-one").click(function(){
$('#form-one').show();
$('#form-two').hide();
});
$("#button-two").click(function(){
$('#form-one').hide();
$('#form-two').show();
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/395730.html
上一篇:如何過濾一組數字并取一定的間隔?
