zama
07-18-2003, 02:06 PM
I have created 3 listboxes that are dependant on the selection of a radio button.
*******************
<cfquery name="Bird" datasource="Invasive">
select Name, ID, Type
from lu_Species
where Type='Bird'
order by name
</cfquery>
<cfquery name="Herptile" datasource="Invasive">
select Name, ID, Type
from lu_Species
where Type='Herptile'
order by name
</cfquery>
<cfquery name="Mammal" datasource="Invasive">
select Name, ID, Type
from lu_Species
where Type='Mammal'
order by name
</cfquery>
<script>
var HerptileList= Array <CFOUTPUT>(#quotedValueList(Herptile.Name)#);
var BirdList= Array(#quotedValueList(Bird.Name)#);
var MammalList= Array (#quotedValueList(Mammal.Name)#);
</CFOUTPUT>
function changeSelect(theValue) {
if(theValue=="Herptile") {
var myArray=HerptileList;
}
if (theValue=="Bird"){
var myArray=BirdList;
}
if (theValue=="Mammal"){
var myArray=MammalList;
}
document.getElementById("theListBox").options.length=0;
for(i=0;i<myArray.length;i++) {
var text=myArray;
var val=myArray;
document.getElementById("theListBox").options[document.getElementById("theListBox").options.length]= new Option(text, val, false, false);
}
}
</script>
<tr>
<td class="top2"><b><font color="red"><select name="theListBox" id="theListBox" style="width:150px"><option>Select Animal Type</select>
<input type="radio" value="Herptile" onclick="changeSelect(this.value)" name="Species_ID">Herptile
<input type="radio" value="Bird" onclick="changeSelect(this.value)" name="Species_ID">Bird
<input type="radio" value="Mammal" onclick="changeSelect(this.value)" name="Species_ID">Mammal
</tr>
*********
The above code works in just fine regards to when a radio button is selected, the contents on the list box change - but I need help with the 'value' of the radio button after a user has selected it, because this is what will be eventually inserted into my database. For example, I want ''American Bullfrog' to be entered instead of 'Herptile'.
At the moment the following code will insert the general animal types (ie: Herptile, Mammal, Bird):
<input type="radio" value="Herptile" onclick="changeSelect(this.value)" name="Species_ID">Herptile
<input type="radio" value="Bird" onclick="changeSelect(this.value)" name="Species_ID">Bird
<input type="radio" value="Mammal" onclick="changeSelect(this.value)" name="Species_ID">Mammal
I however want to insert the specific animal types (ie: values from var HerptileList= Array ('American Bullfrog','Other')
What do I need to change?
Thanks for you help with this
*******************
<cfquery name="Bird" datasource="Invasive">
select Name, ID, Type
from lu_Species
where Type='Bird'
order by name
</cfquery>
<cfquery name="Herptile" datasource="Invasive">
select Name, ID, Type
from lu_Species
where Type='Herptile'
order by name
</cfquery>
<cfquery name="Mammal" datasource="Invasive">
select Name, ID, Type
from lu_Species
where Type='Mammal'
order by name
</cfquery>
<script>
var HerptileList= Array <CFOUTPUT>(#quotedValueList(Herptile.Name)#);
var BirdList= Array(#quotedValueList(Bird.Name)#);
var MammalList= Array (#quotedValueList(Mammal.Name)#);
</CFOUTPUT>
function changeSelect(theValue) {
if(theValue=="Herptile") {
var myArray=HerptileList;
}
if (theValue=="Bird"){
var myArray=BirdList;
}
if (theValue=="Mammal"){
var myArray=MammalList;
}
document.getElementById("theListBox").options.length=0;
for(i=0;i<myArray.length;i++) {
var text=myArray;
var val=myArray;
document.getElementById("theListBox").options[document.getElementById("theListBox").options.length]= new Option(text, val, false, false);
}
}
</script>
<tr>
<td class="top2"><b><font color="red"><select name="theListBox" id="theListBox" style="width:150px"><option>Select Animal Type</select>
<input type="radio" value="Herptile" onclick="changeSelect(this.value)" name="Species_ID">Herptile
<input type="radio" value="Bird" onclick="changeSelect(this.value)" name="Species_ID">Bird
<input type="radio" value="Mammal" onclick="changeSelect(this.value)" name="Species_ID">Mammal
</tr>
*********
The above code works in just fine regards to when a radio button is selected, the contents on the list box change - but I need help with the 'value' of the radio button after a user has selected it, because this is what will be eventually inserted into my database. For example, I want ''American Bullfrog' to be entered instead of 'Herptile'.
At the moment the following code will insert the general animal types (ie: Herptile, Mammal, Bird):
<input type="radio" value="Herptile" onclick="changeSelect(this.value)" name="Species_ID">Herptile
<input type="radio" value="Bird" onclick="changeSelect(this.value)" name="Species_ID">Bird
<input type="radio" value="Mammal" onclick="changeSelect(this.value)" name="Species_ID">Mammal
I however want to insert the specific animal types (ie: values from var HerptileList= Array ('American Bullfrog','Other')
What do I need to change?
Thanks for you help with this