Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  180] [ 2]  / answers: 1 / hits: 41753  / 10 Years ago, mon, july 28, 2014, 12:00:00

I've following HTML code:



<form action=view_rebate_master.php method=post>
<div class=form-group>
<label for=company_name class=col-lg-12>Manufacturer</label>
<div class=col-lg-12>
<select id=company_id class=form-control onchange=GetProductByManufacturerID(this.value) name=company_id>
<option selected=selected value=>All Manufacturers</option>
<option value=40>Test</option>
<option value=42>RK</option>
<option value=49>Blue Nun</option>
<option value=58>Unique Imports</option>
<option value=59>Pernod Ricard</option>
<option value=77>Smoking Loon</option>
<option value=78>Beringer</option>
</select>
</div>
</div>
<div class=col-xs-4>
<div class=form-group>
<label for=product_id class=col-lg-12>Product Name</label>
<div class=col-lg-12>
<select id=product_id class=form-control name=product_id>
<option selected=selected value=>All Products</option>
<option value=12>Riesling</option>
<option value=24>Superio Vodka</option>
<option value=32>Heineken</option>
<option value=33>Strong Bow</option>
<option value=34>Grocery</option>
<option value=35>Ruler</option>
<option value=36>Glass</option>
<option value=37>Brown Bread</option>
<option value=38>White Bread</option>
<option value=55>Cabernet Sauvignon</option>
</select>
</div>
</div>
</div>
<div class=col-lg-12>
<div class=col-xs-5>
<div class=form-group>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type=submit class=btn btn-primary name=search id=search>Search Rebates</button>
</div>
</div>
</div>




The AJAX jQuery code is as follows:



function GetProductByManufacturerID(value) { 
$.ajax({
type: POST,
url: add_rebate_by_quat_volume.php,
data: { manufacturer_id: value, op: },
beforeSend: function() {
$(#product_id).html('<option> Loading ...</option>');
},
success:function(data){
$(#product_id).html('');
$(#product_id).append(data);
}
});
}


I want to make the submit button disable when the AJAX function call is made by changing the value of select control(select control for Manufacturer selection) and it should be disabled till the AJAX success response is received. When AJAX success response will receive the user should be able to click on the submit button. How to achieve this? Thanks in advance.


More From » jquery

 Answers
2

for disable



 $(#search).prop('disabled', true);


for enable



 $(#search).prop('disabled', false);


like below in your function



function GetProductByManufacturerID(value) { 
$.ajax({
type: POST,
url: add_rebate_by_quat_volume.php,
data: { manufacturer_id: value, op: },
beforeSend: function() {
$(#product_id).html('<option> Loading ...</option>');
$(#search).prop('disabled', true); // disable button
},
success:function(data){
$(#product_id).html('');
$(#product_id).append(data);
$(#search).prop('disabled', false); // enable button
}
});
}

[#70020] Friday, July 25, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lucianom

Total Points: 601
Total Questions: 98
Total Answers: 109

Location: Kenya
Member since Fri, Dec 23, 2022
1 Year ago
lucianom questions
Tue, Feb 22, 22, 00:00, 2 Years ago
Wed, May 5, 21, 00:00, 3 Years ago
Sun, Jan 24, 21, 00:00, 3 Years ago
Sat, Aug 15, 20, 00:00, 4 Years ago
Mon, Jun 22, 20, 00:00, 4 Years ago
;