Superfly1611
10-06-2003, 10:21 AM
OK - i'm designing an ASP site - don't worry this is not an ASP question.
i'm using Spans on one particular page and i need to know if the following is possible.....
I have successfully created dynamic <select> boxes in html/jscript before without any hassle at all.
But in this particular instance i need to use spans to create the <option> tags but have the <select> tags outside the spans.
This is a simplified version of what i've tried as it's pretty unreadable with all the ASP in there aswell......
<span id=1>
<option>a</option>
<option>b</option>
<option>c</option>
</span>
<span id=2>
<option>d</option>
<oprion>e</option>
<option>f</option>
</span>
<select id="AAA" onchange="update();">
<option value=1>1</option>
<option value=2>2</option>
</select>
<select>
<span id="ZZZ">
</span>
</select>
I then use a javascript to try and change the contents of the span/select box "ZZZ"
<script language=javascript>
function update()
{
//Get Name of Source Select Box Containing
Source= document.getElementById("AAA");
//Get The Value(ID)of theCategory Selected
id = Source.value;
//Get Span values for That Selected Select Box
element = document.getElementById(id);
//Get Name of Destination Select Box
destElement = document.getElementById("ZZZ");
//Set Values of Destination Select Box
destElement.innerHTML = element.innerHTML;
}
</script>
But it doesn't work.....
I get an error....
"destElement is null or not an object"
Is what i'm trying not possible?
Why don't i just include the <Select> tags inside the spans... because there are 150 rows each with a set of dynamic select boxes on it so i cant really do that as it would mean dynamically creating 150 sets of about 5 spans.
I'm trying to make this as efficient as possible so i don't want to have to hit the server everytime a value is changed.
Is what i'm trying not possible?
i'm using Spans on one particular page and i need to know if the following is possible.....
I have successfully created dynamic <select> boxes in html/jscript before without any hassle at all.
But in this particular instance i need to use spans to create the <option> tags but have the <select> tags outside the spans.
This is a simplified version of what i've tried as it's pretty unreadable with all the ASP in there aswell......
<span id=1>
<option>a</option>
<option>b</option>
<option>c</option>
</span>
<span id=2>
<option>d</option>
<oprion>e</option>
<option>f</option>
</span>
<select id="AAA" onchange="update();">
<option value=1>1</option>
<option value=2>2</option>
</select>
<select>
<span id="ZZZ">
</span>
</select>
I then use a javascript to try and change the contents of the span/select box "ZZZ"
<script language=javascript>
function update()
{
//Get Name of Source Select Box Containing
Source= document.getElementById("AAA");
//Get The Value(ID)of theCategory Selected
id = Source.value;
//Get Span values for That Selected Select Box
element = document.getElementById(id);
//Get Name of Destination Select Box
destElement = document.getElementById("ZZZ");
//Set Values of Destination Select Box
destElement.innerHTML = element.innerHTML;
}
</script>
But it doesn't work.....
I get an error....
"destElement is null or not an object"
Is what i'm trying not possible?
Why don't i just include the <Select> tags inside the spans... because there are 150 rows each with a set of dynamic select boxes on it so i cant really do that as it would mean dynamically creating 150 sets of about 5 spans.
I'm trying to make this as efficient as possible so i don't want to have to hit the server everytime a value is changed.
Is what i'm trying not possible?