Neeraj Prajapati Neeraj Prajapati - 3 months ago 13
PHP Question

get select option value using $(document).ready function in jQuery from multiple dynamic record?

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>

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!');



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.