$.validator.setDefaults({
submitHandler: function(){
var checkedregions = new Array()
var checkedtopics = new Array()

if($("input.regionschk:checked").length > 0)
        {
                $("input.regionschk:checked").each(function(){
                checkedregions.push($(this).val());
            });

}

if($("input.topicschk:checked").length > 0)
        {
                $("input.topicschk:checked").each(function(){
                checkedtopics.push($(this).val());
            });

}


$.post("success.php",
                                {
        
'userregions[]': checkedregions,
                                'usertopics[]': checkedtopics,

                                },
                                function(data){
                                 $("#successmsg").html(data);
                                }
                                );
return false;
 }

});

html:
<input  type="checkbox" class="regionschk" name="regions[]"
value="regions1"  />&nbsp;regions2<br />
        <input  type="checkbox" class="regionschk" name="regions[]"
value="regions2"/>&nbsp;regions2<br />
        <input  type="checkbox"  class="regionschk" name="regions[]"
value="regions3"/>&nbsp;regions3<br />

<input  type="checkbox" class="topicschk" name="topics[]"
value="topic" />&nbsp;topic<br />
<input  type="checkbox" class="topicschk" name="topics[]"
value="topic2" />&nbsp;topic2<br />
<input  type="checkbox" class="topicschk" name="topics[]"
value="topic3" />&nbsp;topic3<br />
<input  type="checkbox" class="topicschk" name="topics[]"
value="topic4" />&nbsp;topic4<br />

PHP:success.php
$regions = $_POST['userregions'];

while (list ($key,$val) = @each ($regions)) {
print $val;
}

$topics = $_POST['usertopics'];
while (list ($key,$val) = @each ($topics)) {
print $val;
}

Reply via email to