What,
exactly, do you expect the code to do? What does it do instead (including any errors)? The "Form" and "AJAX" labels aren't particularly helpful. Instead, state what files (e.g. "ajax_amo.php") the code fragments from, and include the functions they are a part of within the code itself.
There's both too much extraneous code and not enough context to debug it. You should write a
minimal test case and post that.
PHP:
function getHighSchoolDivisionToArray(region)
{
$.get(
"../AMO/ajax_amo.php",
"region=" + region + "&do_action=retrieve_highschool_division_to_array",
function(data) {
$("#txtRetrieveHighSchoolDivisionToArray").html(eval(data));
}
);
}
If you're using
eval, you're most likely doing something
wrong (though
not always). Does ajax_amo.php return JSON? If so, use a
JSON parser (jQuery has one built in; simply specify "json" as the datatype to any
AJAX function, or use
getJSON). Does ajax_amo.php return javascript? If so, then you should use a datatype of "script" for the jQuery AJAX functions (or use
getScript). If ajax_amo.php returns neither, then
data isn't javascript, so
eval(data) will fail. If ajax_amo.php returns HTML that includes <script> elements, you can use a datatype of "html". Script tags are evaluated when inserted into the document (as when you use the
html method).
Form
PHP:
echo "<table>";
echo "<TR>";
...
Ug.
Table abuse. Keep your HTML
semantic, which also means replacing the <center> elements with <label>s, and using styling rather than the <br>s. You could probably get rid of the <div>s and style the <input>s with block display.
You forgot to close the <tr>, but removing the table will make this moot.
The default type for inputs is "text", so you don't need to specify that. Of course, it won't hurt to include the attribute.
Rather than echoing each line, switch out of PHP. It's often more readable.
HTML:
$oListHighSchoolDivision->create();
?>
<div>
<input name='school_region' id='school_region' onkeypress='return ValidKey(event, letters)' value='<?php echo $school_region ?>' title='Enter the region of the highschool' size='30' maxlength='50' onchange='getHighSchoolDivisionToArray(this.value);' onblur='getHighSchoolDivisionToArray(this.value);' />
</div>
<label for="school_region">Region</label>
<div id='txtRetrieveHighSchoolDivisionToArray'>
<input name='division' id='division' onkeypress='return ValidKey(event, letters)' value='<?php echo $division ?>' title='' size='30' maxlength='50' />
</div>
<label for="division">Division</label>
<?php