Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old February 6th, 2004, 12:44 PM
Rich's Avatar
Rich Rich is offline
Administrator
Developer Shed Admin.
 
Join Date: Sep 2003
Location: Fort Lauderdale, FL
Posts: 151 Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 37 sec
Reputation Power: 10
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>

Reply With Quote
  #2  
Old February 9th, 2004, 11:53 AM
Vengeance Vengeance is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 Vengeance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

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:
Originally Posted by Rich
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>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Dynamically populate an HTML select control


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway