Hi,
I'm trying to write a simple AJAX script, that will automatically change the "sub-category" dropdown, based on their State they selected.
Here is a trimmed down version of what I have:
I know ajax_cats.cgi is being run, as I'm outputting debugging stuff to STDERR (in Perl), so I can see whats outputted in the error_log.
Here is an example of what gets outputted when I call ajax_test.cgi?id=Alberta from a browser:
The form HTML I'm using is:
<form name="add_form_1" action="add1.cgi" method="POST">
<%include include_form_1.html%>
</form>
(the <%include thing is a template thing we have, which will include the form based on an included template file)
I don't see any error in FF's "Error Console", so I'm at a bit of a loss as to whats going on :/
Anyone got any suggestions?
TIA!
Andy
I'm trying to write a simple AJAX script, that will automatically change the "sub-category" dropdown, based on their State they selected.
Here is a trimmed down version of what I have:
Code:
<script type="text/javascript" src="/static/jquery.js"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
$("select#ctlJob").change(function(){
$.getJSON("/cgi-bin/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>';
}
$("#catid").html(options);
$('#catid option:first').attr('selected', 'selected');
})
})
})
</script>
I know ajax_cats.cgi is being run, as I'm outputting debugging stuff to STDERR (in Perl), so I can see whats outputted in the error_log.
Here is an example of what gets outputted when I call ajax_test.cgi?id=Alberta from a browser:
Code:
[ {optionValue: "Alberta", optionDisplay: '-- select category --'}, {optionValue: "25001", optionDisplay: 'Calgary > Airconditioning Heating Refridgeration'},{optionValue: "25007", optionDisplay: 'Calgary > Aluminum Metals Plastics Membranes Composite Materials'},{optionValue: "25017", optionDisplay: 'Calgary > Architechs Consultants Planning'}]
The form HTML I'm using is:
<form name="add_form_1" action="add1.cgi" method="POST">
<%include include_form_1.html%>
</form>
(the <%include thing is a template thing we have, which will include the form based on an included template file)
I don't see any error in FF's "Error Console", so I'm at a bit of a loss as to whats going on :/
Anyone got any suggestions?
TIA!
Andy