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:
  #1  
Old February 6th, 2004, 01:44 PM
Rich's Avatar
Rich Rich is offline
Administrator
Developer Shed Admin.
 
Join Date: Sep 2003
Location: Fort Lauderdale, FL
Posts: 152 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 47 m 28 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, 12:53 PM
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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT