IT tech Coding/html
html, form전송을 두개로 하는 방법, 전송버튼 2개로 다른 전송가능
Coding Life
2019. 9. 15. 19:00
html, form전송을 두개로 하는 방법, 전송버튼 2개로 다른 전송가능
궁금해서 여기저기 해결법을 찾아봤습니다.
폼에서 두개의 버튼으로 하나를 누를때는 A라는 곳으로 전송,
다른 버튼을 누르면 B라는 곳으로 전송하는 방법입니다.
<script>
function info_chk() {
return true;
}
function info_chk2(frm) {
frm.action='http://www.test.co.kr/test2/event_ok.php';
frm.submit();
return true;
}
</script>
<form name="user_form" method=post action="http://www.test.co.kr/test/event_ok.php" onsubmit='return info_chk()'>
<input type='submit' value='전송1'>
<input type='button' value='전송2' onclick='return info_chk2(this.form);'>
</form>
전송1을 누렀을때는 정상적으로 test/event_ok.php 호출하고,
전송2를 누르면, test2/event_ok.php를 호출합니다.
자바스크립트를 활용해서 이와 같은 문제는 해결하면 좋습니다.
반응형