| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
Dynamically populate an HTML select control
function setRelationship(seed)
{ var arr = new Array(); switch(seed) { case 0: // takes a comma delimited string value then text displayed arr[0] = "1,JS Applications and Games"; arr[1] = "2,JS Arrays"; arr[2] = "3,JS Behaviours"; arr[3] = "4,JS Browser Compatibility"; arr[4] = "5,JS Colors and Images"; arr[5] = "6,JS Debugging"; arr[6] = "7,JS DOM"; arr[7] = "8,JS Dynamic HTML"; arr[8] = "9,JS Events"; arr[9] = "10,JS Forms"; break; case 1: arr[0] = "1,VB Applications and Games"; arr[1] = "2,VB Arrays"; arr[2] = "3,VB Behaviours"; arr[3] = "4,VB Browser Compatibility"; break; case 2: arr[0] = "1,SQL Games without frontiers"; arr[1] = "2,SQL Code Bank stuff"; arr[2] = "3,SQL Operators"; arr[3] = "4,SQL Platform Compatibility"; break; } // clears any existing items document.forms[0].ddlCategories.options.length = 0 // loops through the array adding item text/value for(var i=0;i<Arr.length;i++) { document.forms[0].ddlCategories.options.length ++; document.forms[0].ddlCategories.options[i].value = arr[i].split(",")[0]; document.forms[0].ddlCategories.options[i].text = arr[i].split(",")[1]; } } <!-- HTML for example --> <SELECT name="ddlLanguages" id="ddlLanguages" style="font-family:Verdana;" onchange="setRelationship(this.selectedIndex)"> <OPTION value="1">Javascript</OPTION> <OPTION value="2">VBscript</OPTION> <OPTION value="3">SQL</OPTION> </SELECT> <BR /> <BR /> <HR width="300" size="1" color="black" /> <BR /> <BR /> <SELECT name="ddlCategories" id="ddlCategories" style="font-family:Verdana;"> <OPTION value=""></OPTION> </SELECT> |
|
#2
|
|||
|
|||
|
Hi everyone,
I tried doing something similar to this but using an ASP:listbox. Everything works fine but when I click my save button, which is an ASP:button, the items in the listbox are deleted. Any thoughts on why this might be happening? TIA, Brian Quote:
|
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Dynamically populate an HTML select control |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|