0

I'm having a problem with the following code:

I have the following jquery call: the problem is that I have several <select name="^DDLColumns1..2..3..4. etc.. controls on my page, however this is only populating the first one: <select name="^DDLColumns1"

anybody know why the select would do this?

<script type="text/javascript" language="javascript">  
        $().ready(function() {
            $.ajax({
                type: "POST",
                url: "Default.aspx/GetColumns",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    $('select[name^=DDLColumns]').get(0).options.length = 0;
                    $('select[name^=DDLColumns]').get(0).options[0] = new Option("Select Column", "-1");

                    $.each(msg.d, function(index, item) {
                        $('select[name^=DDLColumns]').get(0).options[$('select[name^=DDLColumns]').get(0).options.length] = new Option(item, item);
                    });
                },
                error: function() {
                    alert("Failed to load columns");
                }
            });
        });


    </script>

here is a sample of the second group of many....

 <!-- Second Search Condition -->

   <div class="container">
    <fieldset><legend>Search Condition 2</legend>
       <div class="fltlft"> 
            <label>Columns:</label>
           [B] <select name="DDLColumns2" id="DDLColumns2" size="1"></select>[/B]
            <br />
            <label>Group By</label>
            <input name="GroupBy2" type="checkbox" value="" />
        </div>
       <div class="fltlft">
            <label>Condition:</label>
            <select name="DDLConditional2" size="1">
                <option selected="selected">is equal to</option>
                <option>begins with</option>
                <option>is between</option>
                <option>is not equal to</option>
                <option>is greater than</option>
                <option>is less than</option>
            </select>

      </div>
        <div class="fltlft">
            <label>Value:</label> <input name="WhereText2" type="text" size="15" />
            <br /><label id="AndLbl2" style="display:none">and</label>
            <input name="BetweenText2" id="BetweenText2" style="display:none" type="text" size="25" />

        </div>
  </fieldset>
  </div>
      <div class="clearfloat"></div>

what am I doing wrong with the select[name^=DDLColumns] piece? I've seen examples of finding all checkboxes this way...

Thanks anybody...

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Airshow
0

LGR,

I think you need to loop inside the success callback fn.

With a loop counter i counting up from 0 try replacing get(0) with get(i) (4 times).

I'm not sure about $.each . Maybe is disappears if loop is employed.

Airshow

Edited by Airshow: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.