I have multiple select inputs in my page that are dynamically created with same name.
My code:
<select name="area[]" id="area[]" class="area">
<option value="">Select Area</option>
<?
$cities = $this->city_model->get_all($posters->product_id);
foreach($cities as $city) { ?>
<option value="<?=$city->city_id?>"><?=$city->city_name?></option>
<? } ?>
</select>
I want that user select a value from each select input, I am using jQuery function like this:
$('.area').each(function(){
if($(this).val() == "") {
alert("please select Area");
} return false;
});
$('.quantity').each(function(){
if($(this).val() == "" || $(this).val() == 0) {
alert("please select Quantity");
return false;
}
});
$('#form').submit();
i did same same with it, it is also working, but it also submits the form as well, even i restrict it at
<input type="submit" name="something" id="something" value="something" onclick="checkType();return false;">