Reputation: 17
**Script for Drop Down and click event **
OUTPUT : I Randomly select multiple time with different values When I view the console I do get multiple on change events and
they all are execute. I need to obtain the recent drop down value to be executed.
<script type="text/javascript"
src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#dr4').change(function () {
console.log("change");
var name1q=$(this).val();
$('input[type="checkbox"]').click(function () {
console.log("Click");
if ($(this).prop("checked") == true)
{
var data1 = $(this).val();
$.ajax({
type: "POST",
url: "catup123_1.php",
data: {"ajay": data1,"ajay12":name1q},
success: function (html) {
$("#load2222").html(html);
}
});
}
});
});
});
</script>
Upvotes: 0
Views: 34
Reputation: 525
You can directly get the selected value from dropdown i providing you a sample of your code please check it may it help you to solve your issue
<script type="text/javascript"
src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#dr4').change(function () {
console.log("change");
var name1q=$(this).val();
});
$('input[type="checkbox"]').click(function () {
console.log("Click");
if ($(this).prop("checked") == true){
var name1q=$('#dr4').val();
//alert(name1q)
var data1 = $(this).val();
$.ajax({
type: "POST",
url: "catup123_1.php",
data: {"ajay": data1,"ajay12":name1q},
success: function (html) {
$("#load2222").html(html);
}
});
}
});
});
</script>
<select id="dr4">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="checkbox">checkbox
Upvotes: 1