I need to get values for each checkbox and break movement to another page if the user doesn’t check any box.
there is an error but I cant recognize it
$('#Submit').click( function() {
if($('#Search').val() == "")
{alert('please enter your domain without Extuntison');return false;}
results.style.display = 'none';
$('#results').html('');
loading.style.display = 'inline';
$.post('../domain_checker/process.php?domain=' + escape($('#Search').val()),{
}, function(response){
results.style.display = 'block';
$('#results').html(unescape(response));
loading.style.display = 'none';
//$('#results').animate({height : '450px' }, 2000);
results.style.height = '400px';
});
return false;
});
$(function(){
$('#order_Now').click(function(){
var count = $("[type='checkbox']:checked").length;
var val = [];
for(i=0;i<count;i++){
$(':checkbox:checked').each(function(i){
val[i] = $(this).val();
});
}
});
});
and this html page when load ajax
<form action="ordedomain.php" name="formdomain" method="post" id="formdomain" onclick="check_domain_checkBox()">
<div id="results" style="width:450px;" align="left">
</div>
</form>
and this code reloade by ajax in page php
<form action="ordedomain.php" name="formdomain" method="post" id="formdomain" onclick="check_domain_checkBox()">
<input type="checkbox" value="a" id="arrDomain" name="arrDomain">a
<input type="checkbox" value="b" id="arrDomain" name="arrDomain">b
<input type="checkbox" value="c" id="arrDomain" name="arrDomain">c
</form>
That’s simple:
I’m not sure what the
for-loop is doing in your code as you already have theeach().Now you can easily get the count in your
submithandler, if it equals0prevent the submit.Also, you shouldn’t use submit buttons if you want checkboxes; and you can’t use an
idmultiple times (it needs to be unique), use thenameattribute instead: