0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

一つのformで処理を切り替える

Last updated at Posted at 2021-07-09

submitすると、formの中は全て送信されます
その為、一つのformで処理を分けるときにはどこかのタイミングで値を変更できるようにしないといけません。

<form method="post">
    <input type="hidden" name="kind" value="" >
    <button type="button" onclick="return switching_btn(this.form, 'add')">作成
</button>
    <button type="button" onclick="return switching_btn(this.form, 'edit')">編集</button>
    <button type="button" onclick="return switching_btn(this.form, 'delete')">削除</button>
</form>


<script>
// kind切替
function switching_btn(form, f_flg) {
    form.kind.setAttribute("value",f_flg);
    form.submit();
}
</script>

このようにして"kind"の値によって処理を分けることができます

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?