Advertisement
Advertisement
| 02.26.2008 at 11:40AM PST, ID: 23194761 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: |
<!--- This is the code that changes the contents of a list box --->
<cfset mySel = queryNew("")>
<cfset queryAddColumn(mySel, "label", listToArray("test,Option2,Option3,Option4,Option5"))>
<cfset queryAddColumn(mySel, "selval", listToArray("O1,O2,O3,O4,O5"))>
<cfset queryAddColumn(mySel, "description", listToArray("Description for Option1;Description for Option2;Description for Option3;Description for Option4;Description for Option5",";"))>
<form>
<select name="mySelect" onChange="showDesc(this)" >
<option descript="Select one Option.">-Select-</option>
<cfoutput query="mySel">
<option value="#selval#" descript="#description#" >#label#</option>
</cfoutput>
</select>
<span id="description">Select one Option.</span>
</form>
<script>
function showDesc(theSel){
var theDesc = theSel.options[theSel.selectedIndex].getAttribute("descript");
document.getElementById("description").innerHTML = theDesc;
}
</script>
<!--- This is the code I use to populate a list box from a database --->
<tr>
<td>Catagory:</td>
<td> <cfquery name="cata" datasource="#DSN#">
SELECT id,catagory from catagories
</cfquery>
<select name="lcatagory">
<cfoutput query="cata">
<option value="#id#|#catagory#">#catagory#</option>
</cfoutput>
</select></td>
</tr>
|