Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refresh page and update data based on dropdown value

Status
Not open for further replies.

optjco

IS-IT--Management
Apr 13, 2004
185
GB
I have a form that has a dropdown list and several textfields that are all from a DB, is it possible that once the user has selected an ID number from the dropdown that I can get the page to refresh with the relevant data ??

Regards

Olly
 
seach google for "drop down navigation" ... the second link is rather beneficial, of course, you'll need to alter the JS with some ASP to make it work off your DB.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Drexor,
as usual i did not explain myself very well. the dropdown list is a dynamic list from a table in a DB on our server. I have tried the link you suggested above however i cannot get it to generate a list it only shows 1 option. I did look at inserting a jump menu using dreamweaver but could see no way of using dynamic data.

Regards

Olly
 
The link provided shows you how to do a jump menu. In ASP you simply generate the <option> lines. I think we understand your question, but I suspect you don't understand the answer. :)
 
genimuse,
as usual you are right i do not fully understand the answer but will keep trying.

Regards

Olly
 
sample :
<select name="blah" onchange="window.location='whatever.asp?blah='+this.value;">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>

sample 2:
<select name="blah" onchange="document.myForm.submit();">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>

Sample 3:
<%
'connection stuff clipped
set rs = connection.execute("Select ID,whatever from table where something")
%>
<select name="blah" onchange="document.myForm.submit();">
<option>Select an Option</option>
<%
do while not rs.eof
%>
<option value="<%=HTMLEncode(RS("ID"))%>"><%=RS("whatever")%></option>
<%
rs.movenext
loop
%>
</select>


perchance those will be more beneficial.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
PS .. there's info in the faqs about this kind of stuff

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
Ok, here's some code that the generator at the link created for me:
Code:
<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
[COLOR=blue]<option value="[URL unfurl="true"]http://www.apple.com">Apple</option>[/URL]
<option value="[URL unfurl="true"]http://www.bear.com">Bear</option>[/URL]
<option value="[URL unfurl="true"]http://www.coat.com">Coat</option>[/URL][/color]
</select>
</form>
The blue colored part is the portion that we need to generate in ASP. For my example, I'm going to assume that you have a recordset called "rs", that one of the fields in your database is called "LinkName", which contains the name that should appear in the menu, and another field called "LinkURL", which is where the user would go if he selected that option. Your code would look something like this:
Code:
<%
[COLOR=gray]'Code up here to open the recordset[/color]
%>

[COLOR=gray]<!-- Here's the HTML to start the menue -->[/color]
<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">

<%
[COLOR=gray]'Now the code to create the options[/color]
Do While Not rs.EOF
%>
    <option value="<%=rs("LinkURL")%>"><%=rs("LinkName")%></option>
<%
Loop
%>

[COLOR=gray]<!-- Now the HTML to close the menu -->[/color]
</select>
</form>

<%
[COLOR=gray]'Here you close the recordset and possibly the connection[/color]
%>
Does that make sense?
 
Heh, was typing mine the same time as Drexor... he's just faster than me. :)
 
OK, guys thanks for the help and i'm sorry i did not understand.

Genimuse
I have approx 20 records at the moment in the DB, there are seven fields. on my ASP page I have a form with a table in it with the following fields

RecID
Customer
InkColour1
InkColour2
InkColour3
InkColour4
PrintNo

RecId will be my jump menu, the other 6 will be dynamic text. When i select from the jump menu i want to refresh the existing page with the data relating to that RecID without leaving the page if that is possible. So if i make the
Code:
Do While Not rs.EOF
%>
    <option value="<%=rs("RecID")%>"><%=rs("RecID")%></option>
<%
Loop
%>

And then set my action to "PrintCard.asp I am hoping that will work ??!!

Regards

Olly
 
Your value needs to include the url, with the RecID as the querystring for that PrintCard page, along these lines:
Code:
<%
Do While Not rs.EOF
%>
    <option value="[COLOR=blue]PrintCard.asp?ID=[/color]<%=rs("RecID")%>"><%=rs("RecID")%></option>
<%
Loop
%>
The blue part is the add. Where I put "ID=", you'd use whatever request object name PrintCard is expecting (might be "RecID=" or something).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top