Select problem (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


wizard_oz -> Select problem (3/31/2005 15:55:29)

Hey, I have a problem with select command, I have a few selection command with id=1,id=2.....id=10
I would like to add those selection to a database but I can't because I don't know how to call those selection to the link for example <a href addto.asp?menu_id=" here suppose to be the name that I am sending to the other page but if I have few selection how do I do it? Can anyone help me.....?
while not rs5.EOF
	tempname=""
		meal=rs5("id_categ")
		while not rs.EOF
				if rs("id_categ")=meal then
					tempname=rs("category")
				end if
					rs.MoveNext
		wend
		Response.Write "<tr><td>" & tempname & "</tr></td>"
		rs.MoveFirst
		Response.Write "<td>"
		if tempname<>"" then
			Response.Write "<SELECT id=select1 name=" & count & ">"
			Response.Write "<option selected value=1>choose menu</option>"
				while not rs.EOF
				if rs("id_categ")=meal then
					Response.Write "<option value=" &  rs("id") & ">" & rs("food") & "</option>"
				end if
					rs.MoveNext
				wend
			Response.Write "</SELECT>"
		end if




dzirkelb1 -> RE: Select problem (3/31/2005 16:29:22)

are you trying to pass a variable or are you trying to pass specefic data? is the data coming from a form? (sorry, I couldn't really understand by the code what you were trying to do with the lin)

by variable it is:

addto.asp?var="& var1 & var2 & var3

by form it is:

addto.asp?var="&Request.Form("var1")&Request.form("var2")

is that anything close what what you are asking or am I waaay off? :)




wizard_oz -> RE: Select problem (4/1/2005 3:09:58)

What I did is I used the select command many time (like 8 times) so instead to write the select command 8 time I used this code. I understand what you were say about the var but how do I know the var name from the select ?




Spooky -> RE: Select problem (4/1/2005 4:25:20)

Is the variable meant to form the select statement? eg : "select * from table where column="&request("variable")




wizard_oz -> RE: Select problem (4/1/2005 9:21:02)

sorry I didn't understand what you were saying




dzirkelb1 -> RE: Select problem (4/1/2005 10:38:30)

I think I'm following you...you have 8 select statements (or somewhere around that) and you would like to pass the values of those select statements to a next page via hyperlink...if that is the case, then you will have to define each variable within the select statement to pass...it is like this:

on a spooky diet, after all the 2nd include file (include1), you will place:

<%
var1=fp_field(fp_rs,"field1")
var2=fp_field(fp_rs,"field2")
var3=fp_field(fp_rs,"field3")
var4=fp_field(fp_rs,"field4")
%>

You will do that for each select statement for variables you would like to create; however, make sure no duplicate variable names are created (in the above, you would replace items in bold)

Then, in you hyperlink you would do:

<a href="link.asp?var="& var1 & var2 & var3 & var4

you would have to modify that to be specefic to your needs...is that what you are wishing to do?




wizard_oz -> RE: Select problem (4/1/2005 11:14:19)

I don't know those command you talked about but let me explain to you again, you are right about the 8 (or more) select statment, but it is in a loop (look at the code above) , my question is if I am choosing from the drop down menu (the select option....) how do I keep the chosen item? I can't do something like :
var=select
so ow do I do it?




dzirkelb1 -> RE: Select problem (4/1/2005 11:23:37)

Are you trying to pass whatever is selected in the select drop down? if that is so, then you would request the select name...

link.asp?var="&request.form(&name&)

Since the name of your select is a variable, I think that is the right syntax...am I getting any closer to what you want? :)




wizard_oz -> RE: Select problem (4/1/2005 11:29:53)

I think you got it I will try it please look for me if there are any problems, by the way one more thing, can I do loop from array to the follwing link:
addto.asp?var="& var(1) & var(2) & var(3)
can I do :
addto.asp?var="& for i=1 to 3
var(i)
next







wizard_oz -> RE: Select problem (4/1/2005 11:36:34)

do i put it at the same page where the selections are?
and you just gave me one selection, you forgot that I have 8 more selection
link.asp?var="&request.form(&name&)




dzirkelb1 -> RE: Select problem (4/1/2005 11:42:38)

Are you passing the values of the array to another array or to a page to call the values in a select statement or something besides placing them into another array?

You generally have to say something=something on the link...so it would be something similar to:

addto.asp?var1="&myArray(1)&"&"&"var2="&myArray(2)&"&"&"var3="&myArray(3)

For a loop, you could do something like:

<%
for i=1 to 8
myArray(i)=var&i
link=link&"var"&i&"="&"""&myArray(i)&"&"&
next
%>

then, the link would be:

addto.asp?&link

thats not testd, but should give a general idea on how to do it




wizard_oz -> RE: Select problem (4/2/2005 6:56:52)

	dim arrSend(10)
Response.Write "<a href=addtobasket.asp?arrSend(1)="&arrMeal(1)& "&" & "arrSend(2)="&arrMeal(2) & ">click</a>"

can you please try to make a look from the line at the code?




yogaboy -> RE: Select problem (4/2/2005 8:39:51)

I just answered the othe question you've put up related to this, but having read this I suppose you can pretty much ignore that! :)

Forgive me for asking the obvious question, but if you have 8 select menus and you want to pass them over to the next page, wouldn't it be easier to use the POST method with a Submit button and Request.Form("arrSendwhatever") on the next page??

Iain




dzirkelb1 -> RE: Select problem (4/4/2005 12:36:32)

Response.Write "<a href=addtobasket.asp?arrSend(1)="&arrMeal(1)& "&" & "arrSend(2)="&arrMeal(2) & ">click</a>"

The bolded items need to be changed. Change them to something simple like arrSend1 and arrSend2...then, on your second page, you would have to call them like <%request.querystring("arrSend1)"%>




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
9.179688E-02