Need Help, Both submit button works same, i need both submit button works differently, the one button override other button

Joined
Nov 9, 2022
Messages
2
Reaction score
0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" >


<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>


<!-- <title>Redirect page dependent dropdown</title> -->
</head>
<body>

<div class="container pt-5">
<div class="row d-flex justify-content-center">
<div class="col-md-5 p-4 border">

<!-- <h2>Redirect page dependent dropdown</h2> -->

<form name="myform" id="myForm">
<select class="form-select" id="category_sel" size="1">
<option value="" selected="selected">--Select--</option>
</select>
<br>
<br>

<select class="form-select" id="topic_sel" size="1">
<option value="" selected="selected">--Select--</option>
</select>
<br>
<br>
<center>

</form>
</div>
</div>
</div>
<button type="button" id="filter_s" class="btn btn-primary">Up Regulated</button>
<script>
var countryStateInfo = {
"Tolerant Normal Potassium": {
"Tolerant Low Potassium": ["http://www.google.com" ],
"Sensitive Normal Potassium": ["http://www.amazon.com"],
},
"Sensitive Normal Potassium": {
"Sensitive Low Potassium": ["http://www.msn.com"],
},
"Tolerant Low Potassium": {
"Sensitive Low Potassium": ["http://www.youtube.com"],
},
}
window.onload = function () {
//Get html elements
var category_sel = document.getElementById("category_sel");
var topic_sel = document.getElementById("topic_sel");
var category_sel = document.getElementById("category_sel");
var topic_sel = document.getElementById("topic_sel");
//Load countries
for (var country in countryStateInfo) {
category_sel.options[category_sel.options.length] = new Option(country, country);
}
category_sel.onchange = function () {
topic_sel.length = 1; // remove all options bar first
if (this.selectedIndex < 1)
return; // done
for (var state in countryStateInfo[this.value]) {
topic_sel.options[topic_sel.options.length] = new Option(state, countryStateInfo[this.value][state]);
}}}
$(document).ready(function(){
$("#filter_s").click(function () {
if($("#topic_sel option:selected").val() !== ""){
window.location.href = $("#topic_sel").val();

}})})


</script>

<button type="button" id="filter_s1" class="btn btn-primary">down Regulated</button>
<script>
var countryStateInfo = {
"Tolerant Normal Potassium": {
"Tolerant Low Potassium": ["http://www.yahoo.com" ],
"Sensitive Normal Potassium": ["http://www.bing.com"],
},
"Sensitive Normal Potassium": {
"Sensitive Low Potassium": ["http://www.flipkart.com"],
},
"Tolerant Low Potassium": {
"Sensitive Low Potassium": ["http://www.canva.com"],
},
}
window.onload = function () {
//Get html elements
var category_sel = document.getElementById("category_sel");
var topic_sel = document.getElementById("topic_sel");
var category_sel = document.getElementById("category_sel");
var topic_sel = document.getElementById("topic_sel");
//Load countries
for (var country in countryStateInfo) {
category_sel.options[category_sel.options.length] = new Option(country, country);
}
category_sel.onchange = function () {
topic_sel.length = 1; // remove all options bar first
if (this.selectedIndex < 1)
return; // done
for (var state in countryStateInfo[this.value]) {
topic_sel.options[topic_sel.options.length] = new Option(state, countryStateInfo[this.value][state]);
}}}
$(document).ready(function(){
$("#filter_s1").click(function () {
if($("#topic_sel option:selected").val() !== ""){
window.location.href = $("#topic_sel").val();

}})})
</script>
</body>
</html>
 
Joined
Mar 11, 2022
Messages
227
Reaction score
32
Use code to embrace your scripts. Hard to read that way.

It's JQuery. I hate JQ. Maybe some JQ enthusiasts out there can help you.
 
Joined
Nov 24, 2022
Messages
14
Reaction score
2
Reason for this is because you are trying to load 2 scripts. And because it's inside html, it executes first, then ends all, then starts the second one. So, the issue is when you seperate scripts. Why would you do that? Just make one script that can do two different results. Right now it's like you have only one script, not two.

You populate results from the second script. What you need to do is to make some if statements.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top