13
Answers

without click on button,its directly shows result in mvc

Photo of Guest User

Guest User

3y
934
1

here is the form in which on brand list dropdown it'll show all the brands from DB but on select of any brand name it will go to the next page on button click but it doesnt work like that when i select any brand name fom dropdown its directly goes to the next page not on the click of the button

Here the code i am trying to do

Answers (13)

3
Photo of Sachin Singh
NA 55.8k 87.9k 3y
Test this
  1. $("#budgetModelFilter").change(function () {  
  2.    var bid= $('#budgetModelFilter option:selected').text();  
  3.        if ($('#custom_select option:selected').text() != "Model") {  
  4.             return false;  
  5.         }  
  6.       else{  
  7.         window.location.href="/Car/CarList?brand=" +bid;  
  8. }  
  9.           
  10.     });  
 
Accepted
3
Photo of Uttam Kumar
534 2.3k 285.1k 3y
you should remove the budgetModelFilter change event
 
  1. $("#budgetModelFilter").change(function () {  
  2.     //...  
  3. }  
 
 Instead you write it in a button click event
 
  1. $("#btnFrontSearch").click(function() {  
  2.     if ($('#custom_select option:selected').text() != "Model") {  
  3.             return false;  
  4.         }  
  5.   
  6.         window.location.href="/Car/CarList?brand=" + $('#budgetModelFilter option:selected').text();  
  7. });  
 
2
Photo of Sachin Singh
NA 55.8k 87.9k 3y
Use this $("#budgetModelFilter").click(function () { var bid= $('#budgetModelFilter option:selected').text(); if ($('#custom_select option:selected').text() != "Model") { return false; } else{ window.location.href="/Car/CarList?brand=" +bid; } });
1
Photo of Uttam Kumar
534 2.3k 285.1k 3y
You can write two trigger event one dropdown change event and another click event 
  1. $("#budgetRangeFilter").change(function() {  
  2.     //... You can show list of car from here  
  3. }  
Once this is done
  1. $("#btnFrontSearchApply").click(function() {  
  2.     //... You write your logic here  
  3. }  
 
1
Photo of Guest User
Tech Writer 254 14k 3y
Uttam Kumar
 
on budget search click its shows dropdown of budget like
{ Text: "Any budget", Value: "0-500000000" },
{ Text: "1 Lakh - 5 Lakh", Value: "100000-500000" },
{ Text: "5 Lakh - 10 Lakh", Value: "500000-1000000" },
{ Text: "10 Lakh - 20 Lakh", Value: "1000000-2000000" },
{ Text: "20 Lakh - 50 Lakh", Value: "2000000-5000000" },
{ Text: "50 Lakh - 1 Crore", Value: "5000000-10000000" },
{ Text: "Above 1 Crore", Value: "10000000-500000000" }
 
on click of list option its show list of cars according to budget select 
 
 
 
1
Photo of Uttam Kumar
534 2.3k 285.1k 3y
What do you want to do with budget search click?
1
Photo of Guest User
Tech Writer 254 14k 3y
if i use 
(btnFrontSearch)
its works fine for brand search but not for buget search 
 
1
Photo of Guest User
Tech Writer 254 14k 3y
Uttam Kumar
 
I use your scenario but I use two buttons 
 
<button id="btnFrontSearch" type="button" class="btn btn_search">Search</button> //for brand search
<button id="btnFrontSearchApply" class="btn btn_search hidden" type="submit">Search</button> //for budget search
 
 
1
Photo of Guest User
Tech Writer 254 14k 3y
Sachin Singh
I try your scenario but doesn't work  
1
Photo of Guest User
Tech Writer 254 14k 3y

Attachment js.zip

Uttam Kumar
 
1
Photo of Uttam Kumar
534 2.3k 285.1k 3y
Can you search for the element budgetModelFilter which may be bound to an event in jquery or javascript triggering to redirect to next page?
1
Photo of Guest User
Tech Writer 254 14k 3y

Attachment brand.zip

here is the code
1
Photo of Muhammad Imran Ansari
252 7.6k 328.1k 3y
@Nirvriti,
Where is the code? Further you can check with Set AutoPostback to false of dropdown.