D
DartmanX
I am attempting to create a set of chained selectors (one <select> uses
AJAX to read values for the next <select>, and so on). My AJAX code
works fine, and returns the text of the entire <select> statement. I
have defined a separate <DIV> for each selector to be created inside
of.
However, what is returned is ONLY text. When I attempt to create second
selector based on the value of the first, the javascript console is
happy to inform me that the first element doesn't exist.
So, if I get this back from the AJAX function:
<select name="selState">
<option>Alabama</option>
<option>Arizona</option>
....
</select>
How do I convert this to an actual Element, so that is is visible as
part of the document tree?
Jason
/**
This function generates an AJAX request to create a <select> filled
with the state names.
*/
function getStates() {
var docname='ajax.php?action=1';
http.open('get',docname);
http.onreadystatechange = function() {
if (http.readyState == 4) {
var response = http.responseText;
document.getElementById('stateSelect').innerHTML = response;
}
};
http.send(null);
}
function getCounties() {
if (document.getElementById('selState') == null) {
alert('No selState node!');
}
var docname='ajax.php?action=1+param=' +
document.getElementById('selState').value;
http.onreadystatechange = function() {
if (http.readyState == 4) {
var response = http.responseText;
document.getElementById('countySelect').innerHTML = response;
}
};
}
AJAX to read values for the next <select>, and so on). My AJAX code
works fine, and returns the text of the entire <select> statement. I
have defined a separate <DIV> for each selector to be created inside
of.
However, what is returned is ONLY text. When I attempt to create second
selector based on the value of the first, the javascript console is
happy to inform me that the first element doesn't exist.
So, if I get this back from the AJAX function:
<select name="selState">
<option>Alabama</option>
<option>Arizona</option>
....
</select>
How do I convert this to an actual Element, so that is is visible as
part of the document tree?
Jason
/**
This function generates an AJAX request to create a <select> filled
with the state names.
*/
function getStates() {
var docname='ajax.php?action=1';
http.open('get',docname);
http.onreadystatechange = function() {
if (http.readyState == 4) {
var response = http.responseText;
document.getElementById('stateSelect').innerHTML = response;
}
};
http.send(null);
}
function getCounties() {
if (document.getElementById('selState') == null) {
alert('No selState node!');
}
var docname='ajax.php?action=1+param=' +
document.getElementById('selState').value;
http.onreadystatechange = function() {
if (http.readyState == 4) {
var response = http.responseText;
document.getElementById('countySelect').innerHTML = response;
}
};
}