Reputation: 541
Here is my code
foreach($test as $val){
<select name="change" id="change-<?=$val['id']?>" data-id="<?php echo $val['id'];?>">
<option value="">Select Value</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
}
I want every different record blank value alert in every 3 min. so please help me. thanks!
$(document).ready(function(e) {
var change = $('#change').val();
if (change == '') {
alert('Please Select Shipping Destination!');
}
});
Upvotes: 0
Views: 2267
Reputation: 2946
For the interval you can use plain JavaScript's setInterval() method.
In order to find and iterate over all your select
fields, you can use jQuery's "starts with" selector and .each()
method.
This should work:
$(document).ready(function(e) {
setInterval(function() {
$("select[id^='change-']").each(function(i) {
var value = $(this).val();
if (value == '') {
alert('Please Select Shipping Destination!');
}
});
}, 3 * 60 * 1000);
});
Note that this will create an alert for every select
that is empty. Probably not very user friendly.
Upvotes: 2