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:
...and the SELECT forms are as follows:
Now, this was working perfectly for me this morning - and now its giving me a weird error :
Error: $("#Continent") is null
Source File: Line: 8
Now, I know #Continent exists - as I can see it fine in the HTML.
Anyone got any ideas? I'm at a real dead end with this
TIA
Andy
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');
})
})
})
...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>
Now, this was working perfectly for me this morning - and now its giving me a weird error :
Error: $("#Continent") is null
Source File: Line: 8
Now, I know #Continent exists - as I can see it fine in the HTML.
Anyone got any ideas? I'm at a real dead end with this
TIA
Andy