I am trying to use multiple submit forms in javascript but it opens about:blank
along with the requested form actions URLs in next tab
my code:
<form class="search_content" action="/" method="post" target='_blank' id="form1" name="form1">
<input type="text" id="lname" name="lname" required>
<input type="checkbox" id="myCheck">
<input type="checkbox" id="myCheck1" >
<input type="checkbox" id="myCheck2" >
</form>
<button onclick="submitForms()">
Go Search !
</button>
my javascript code
as you see I use the check box to enable the different action URLs... when I run my code, it will open three new tabs and one "about:blank" tab. which should not open in my code
can anyone help me with how to do this kind of multiple action method with javascript and checkbox
<script>
function submitForms() {
var checkBox = document.getElementById("myCheck");
var checkBox1 = document.getElementById("myCheck1");
var checkBox2 = document.getElementById("myCheck2");
if (checkBox.checked == true){
document.getElementById("form1").action =
"https://www.example.com/action_page.php";
document.getElementById("form1").target='_blank';
document.getElementById("form1").submit();
}
if (checkBox1.checked == true){
document.getElementById("form1").action =
"https://www.example1.com/action_page.php";
document.getElementById("form1").target='_blank';
document.getElementById("form1").submit();
}
if (checkBox2.checked == true){
document.getElementById("form1").action =
"https://www.example2.com/action_page.php";
document.getElementById("form1").target='_blank';
document.getElementById("form1").submit();
}else{
}
}
</script>