I am trying to make a dynamic call to php script using jquery. I have multiple input checkboxes
<input type="checkbox" id="driver[0]" value="log.example.com">
<input type="checkbox" id="driver[1]" value="api.example1.com">
<input type="checkbox" id="driver[2]" value="mail.example.com">
Using jquery, this is what I am trying to do,
$(document).ready(function() {
$("#driver[0]").click(function(event){
if($(this).is(':checked')){
var domain = $(this).val();
//alert(domain);
$("#stage").load('call.php', 'submit=submit&domain='+domain);
}
});
});
So as you can see, the jquery requires a selector here #driver[0]
, which in my case can be either one of them only. So does that mean that I have to write seperate function for each checkbox?
Here is how the data is getting updated into the page.
<div id = "stage" style = "background-color:#eee;">
STAGE
</div>
Since all the domains are getting dynamically generated, I am thinking of a more adaptive way to deal with this, but I am having no luck.
Thanks,