回答編集履歴
1
加筆修正
answer
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
```html
|
2
|
+
<input type="submit" value="ログイン" onclick="actionA();"/><br />
|
3
|
+
<input type="submit" value="新規登録" onclick="actionB();"/><br />
|
4
|
+
```
|
5
|
+
は
|
6
|
+
```html
|
7
|
+
<input type="button" value="ログイン" onclick="actionA();"/><br />
|
8
|
+
<input type="button" value="新規登録" onclick="actionB();"/><br />
|
9
|
+
<input type="hidden" name="a_or_b" value="" /><br />
|
10
|
+
```
|
11
|
+
にして、
|
12
|
+
```javascript
|
13
|
+
$(".btn").on("click", function actionA(){
|
14
|
+
document.getElementById("form").action = "./mail.html";
|
15
|
+
```
|
16
|
+
を
|
17
|
+
```javascript
|
18
|
+
$(".btn").on("click", function actionA(){
|
19
|
+
document.form.action = "./mail.html";
|
20
|
+
document.form.a_or_b.value = "a";
|
21
|
+
...
|
22
|
+
...
|
23
|
+
document.form.submit();
|
24
|
+
}
|
25
|
+
```
|
26
|
+
みたいにする感じですが、いかがでしょうか。
|
27
|
+
---
|
1
28
|
例えば、隠し送信パラメータ`<input type="hidden" name="a_or_b" />`に、AボタンBボタンのどれを押したかを示す値を納めてからsubmitしてはいかがでしょうか。
|
2
29
|
あわせて、`<input type="submit" ~onclick="" />`はすべて`<input type="button" ~onclick="" />`にしましょう。
|
3
|
-
`
|
30
|
+
`document.getElementById("form").submit();`にてフォーム送信できますので。
|