Hi,

I'm really really hoping someone can help me here.

Using AJAX, I wrote a little function that will call a .cgi script on
our server, and populate 2 different select fields.

The JS code is:

[CODE] $(function(){
         $("select#Continent").change(function(){
                        alert("HERE");
                 $.getJSON("/cgi-bin/careers/ajax_cats.cgi",{id: $(this).val()},
function(j){

                         var options = '';
                         for (var i = 0; i <j.length; i++) {
                                 options += '<option value="' + 
j[i].optionValue + '">' + j
[i].optionDisplay + '</option>';
                         }
                         $("#CityProvince").html(options);
                         $('#CityProvince option:first').attr('selected', 
'selected');
                 })
         })
 })


 $(function(){
         $("select#CityProvince").change(function(){
                 $.getJSON("/cgi-bin/careers/ajax_cats_city.cgi",{id: 
$(this).val(),
main_id: $('#Continent').val()  }, function(j){

                         var options = '';
                         for (var i = 0; i <j.length; i++) {
                                 options += '<option value="' + 
j[i].optionValue + '">' + j
[i].optionDisplay + '</option>';
                         }
                         $("#SubCategory").html(options);
                         $('#SubCategory option:first').attr('selected', 
'selected');
                 })
         })
 })[/CODE]

...and the SELECT forms are as follows:

[CODE]  <div class="row clear ">
          <label for="Continent" class="name">Continent: </label>
          <div class="value">
                  <%Plugins::ULTRAGlobals::Format_Select_Field
($Continent,'Continent')%>
              <select name="Continent" id="Continent">
                <%loop select_loop%>
                  <option value="<%value%>" <%if selected%>selected="yes"<
%endif%>><%name%></option>
                <%endloop%>
              </select>
          </div>
        </div>


        <div class="row clear ">
          <label for="CityProvince" class="name">City/Province: </label>
          <div class="value">
              <select name="CityProvince" id="CityProvince">
                  <option value="">-- select continent first --</option>
              </select>
          </div>
        </div>



        <div class="row clear ">
          <label for="SubCategory" class="name">Sub-Category: </label>
          <div class="value">
              <select name="SubCategory" id="SubCategory">
                  <option value="">-- select city first --</option>
              </select>
          </div>
        </div>[/CODE]

Now, this was working perfectly for me this morning - and now its
giving me a weird error :

Error: $("#Continent") is null
Source File: [url]http://www.domain.com/cgi-bin/careers/add.cgi[/url]
Line: 8

Now, I know #Continent exists - as I can see it fine in the HTML.

For anyone who wants to test -try:

[url]http://www.sweetcareers.com/cgi-bin/careers/add.cgi[/url]

User: ultranerds
Pass: ultranerds

Any help uis greatly appreciated - I can't see for the life of me why
its suddently stopped working in the last few hours - we havn't
changed anything - and it was working absolutly perfectly before :(

TIA

Andy

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to