SPrelewicz
Programmer
This may be long...
Problem - I am dynamically creating some form elements on a page based on prewvious selection.
Step 1 - User clicks an area on a map, Group of checkboxes is created based on selection. name=state id-state. this I have working no problem using a <div> and innerHTML() in that div.
The user then should be able to select a few state checkboxes and Then a lsit of cities should appear in another <div> via a multi select.
Code -
My specific error is happening at -
var selectedItems = getSelectedCheckbox(buttonGroup);
I guess its not seeing the state checkbox group? -
var buttonGroup=document.foo.state;
Am I missing something, or is it not being seen because the checkbox group itself was created via a similar function with innerHTML?
Thanks in advance.
Scott
Problem - I am dynamically creating some form elements on a page based on prewvious selection.
Step 1 - User clicks an area on a map, Group of checkboxes is created based on selection. name=state id-state. this I have working no problem using a <div> and innerHTML() in that div.
The user then should be able to select a few state checkboxes and Then a lsit of cities should appear in another <div> via a multi select.
Code -
Code:
function loadCities() {
var buttonGroup=document.foo.state;
var string;
var selectedItems = getSelectedCheckbox(buttonGroup);
if (selectedItems.length != 0) {
retArr.length = selectedItems.length;
for (var i=0; i<selectedItems.length; i++) {
string += "state=" + buttonGroup[selectedItems[i]].value + ";";
}
}
if (typeof window.ActiveXObject != 'undefined' ) {
xmlDoc2 = new ActiveXObject("Microsoft.XMLHTTP");
xmlDoc2.onreadystatechange = processCities;
}
else {
xmlDoc2 = new XMLHttpRequest();
xmlDoc2.onload = processCities;
}
xmlDoc2.open( "GET", "/cgi-bin/xmlmoc.cgi?action=cities&"+string, true );
xmlDoc2.send( null );
}
function processCities() {
var cityArray=new Array();
var valArray;
var string_out;
document.getElementById('Cities').innerHTML="<select name='cities' id='cities' MULTIPLE>";
if (xmlDoc2.readyState == 4) {
// only if "OK"
if (xmlDoc2.status == 200) {
delX= ":";
delY= ",";
valArray = xmlDoc2.responseText.split(delX);
var valArraylen = valArray.length - 1;
string_out += "Select Your Cities:<br>";
for (var i=0; i <= valArraylen; i++ ) {
cityArray = valArray[i].split(delY);
if (cityArray[1] == undefined) {continue;}
string_out += "<option name=city value="+ cityArray[0] +">" + cityArray[1];
}
} else {
alert("There was a problem retrieving the data:" + xmlDoc2.statusText);
}
}
document.getElementById('Cities').innerHTML= string_out;
document.getElementById('Cities').innerHTML= "</select>";
}
My specific error is happening at -
var selectedItems = getSelectedCheckbox(buttonGroup);
I guess its not seeing the state checkbox group? -
var buttonGroup=document.foo.state;
Am I missing something, or is it not being seen because the checkbox group itself was created via a similar function with innerHTML?
Thanks in advance.
Scott