ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

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
  #1  
Old June 18th, 2003, 08:28 AM
fmh002 fmh002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 38 fmh002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m
Reputation Power: 5
dynamic drop down box

hello

i have two drop down boxes: student id and student name on a web form.

a database (ms access) has the student id and student name fields in a table.

the drop down boxes should get their values from the table's fields respectively.

i am ok with that (using asp) but my requirement is as follows:

once i select a studentid from textbox1 then automatically the textbox2 should be selected with the corresponding student name.

how can i do this using asp? or can javascript do the job too?

thnx in advance,
fmh002

Reply With Quote
  #2  
Old June 18th, 2003, 08:52 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Two

ways you can do this.

First approach
--------------------
Dynamically build your first combobox Server Side with the student id's so that you end up having:

<select name="slcId" onchange="Load(this.options[selectedIndex].value)">
<option value="123">123</option>
<option value="456">456</option>
. . .
. .
.
</select>

As for the second combobox, don't build immediately.

The idea behind this approach is that when a user select an item from your first combobox, it call a javascript function Load()
notice the onchange attribute.
Now the javascript function should be placed inside your <head>...</head> section of your page.

What the function does is *refresh* the page(calling itself) passing the selected value by the user through/as a QueryString parameter.

You then retrieve the parameter and re-execute another SQL Query to build the second combobox.

Now the downfall of this approach is that a *refresh* of the page occurs and you might not want that.



The second approach
--------------------------
Is almost like the first one, but you build the two comboboxes Server side. The second combobox should be selected to an empty <option>...</option>.

Also note that the second combobox should look something like:
<option value="123">John Doe</option>
that is the value attribute should be set to the student's ID

Then inside the first combobox, have set the same way as in the first approach. Have call a javascript function like Load() for example and inside the function make the selected item inside the second combobox equal to the student Id that has been selected from the first combobox.

There are plenty of example out there...search google.com for any if you'd like.

Hope this helps!
Sincerely

Vlince

Reply With Quote
  #3  
Old June 18th, 2003, 08:59 AM
fmh002 fmh002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 38 fmh002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m
Reputation Power: 5
thnx for the prompt feedback. let me see how far i can implement it on my site.

peace,
fmh002

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > dynamic drop down box


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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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