473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

One Pick List Based off of Another

Stang02GT
1,208 Expert 1GB
Hey guys I'm having some trouble's with the following code.

Here is what I am trying to do. I have two pick list options (drop downs) and the first one pulls from a table with department names in it, these department names are also found in the PhoneBook table which the second pick list is TRYING to pull from.

Here is my issue, the first option works fine the departments display no problem. How can I change the following code to allow the Requestor field to be updated based on what the user selects in the Department field?

Basically if you pick Finance in the department field then the Requestor field should then update to show only people who work in the Finance department.

Expand|Select|Wrap|Line Numbers
  1. <tr>
  2. <td valign="center">Department</td>
  3. <td>
  4. <select name="REQUESTOR_DEPT" onChange="">
  5. <option value="">Choose One
  6. <%sql = "SELECT APP_LIST_VALUE_DESC from  TICKER_APP_LIST_VALUE WHERE APP_LIST_ID = 5 ORDER BY APP_LIST_VALUE ASC "                
  7. set rs = server.CreateObject("adodb.recordset")
  8. rs.Open sql, conn
  9. while not rs.eof 
  10. Response.Write("<option value='"&rs(0)&"'")
  11. if cstr(REQUESTOR_DEPT)=cstr(rs(0)) then
  12. Response.Write(" selected ")
  13. end if
  14. Response.Write(">"&rs(0))
  15. rs.movenext
  16. wend
  17. rs.close
  18. set rs = nothing
  19. %>  
  20. </select></td>
  21. <td></td>
  22. <td></td>
  23. </tr>
  24. <tr>
  25. <td valign="center">Requestor</td>
  26. <td><select name="PROF_ANAYLST_ID" onChange="">
  27. <option value="">Choose One
  28. <%sql = "SELECT LNAME+' '+FNAME FROM dbo_phonebook WHERE Department LIKE ' " & REQUESTOR_DEPT  " '"
  29. set rs = server.CreateObject("adodb.recordset")
  30. rs.Open sql, conn2
  31. while not rs.eof 
  32. Response.Write("<option value='"&rs(0)&"'")
  33. if cstr(PROF_ANAYLST_ID)=cstr(rs(0)) then
  34. Response.Write(" selected ")
  35. end if
  36. Response.Write(">"&rs(0))
  37. rs.movenext
  38. wend
  39. rs.close
  40. set rs = nothing
  41. %>  
  42. </select></td>
  43. </tr>
May 6 '10 #1
3 1994
jhardman
3,406 Expert 2GB
I'm afraid asp is not set up to do this, remember ASP runs on the server and the code is dead and gone by the time the user even sees the form.

You will have to use some combination of javascript or ajax along with the ASP code to change the second select on the fly.

Jared
May 6 '10 #2
Stang02GT
1,208 Expert 1GB
Ok so maybe some onclick javascript event that will update the second picklist value. Or something along those lines.


Thanks for the advice!
May 7 '10 #3
jhardman
3,406 Expert 2GB
exactly. I've seen several solutions for this type of problem, but they all depend on Javascript or Ajax. In the minimum you could submit the form and use asp to re-build the form, but notice it still uses javascript to submit the form when the first select changes, and I think that approach is a little less-favored. I think it's a pretty common javascript problem, you should be able to google and get a hundred solutions.

Jared
May 7 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: CJM | last post by:
Not sure if this is entirely on-topic.... I would ideally like to present an initial list based on one DB table. The user selects an item, and the 2nd list is updated to show items from the DB...
1
by: CrystalQuery | last post by:
Is there any way I can put those two together, so users can pick a value in the list if they find the value that they are looking for; otherwise, they can simply type any valuea within the pick...
2
by: kmnotes04 | last post by:
Is it possible to link one drop-down box to another? For example, if a name is chosen from a drop-down list, can another drop-down list then automatically display the person's office as a result of...
10
by: Mark Winter | last post by:
Hello, I am wondering if someone could point me in the right direction to figure out how to create a dynamic form. I have been developing programs in perl and oracle and have recently switched...
1
kcdoell
by: kcdoell | last post by:
Hello: I have a table called "Products". In there are two fields; "Product Name" & "Product Category". I have about 24 products but only 3 product categories (for example Product Category A, B,...
3
Jerry911
by: Jerry911 | last post by:
I have a form that uses a pick list to select a specified date/time range based on the case value. Case 1-7 have pre-defined date/time functions, but case 8 is for a custom date/time range. I only...
1
by: deerick | last post by:
Hi there I want to know how to add a drop down list based on value from a table in an asp form. Then I want the user to be able to submit the form, and the drop down list value that they have...
6
by: troy_lee | last post by:
I have a continuous form that has one combo box (cbo1) with the selectable values of "Removal" and "Installation". I would like to change another combo box (cbo2) value list based on the selection...
14
by: mjvm | last post by:
HI, I have had a search for the answer to this question, but I can't transfer what I am reading to my database. I don't know enough about the language required, but have been able to get my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.