Click to See Complete Forum and Search --> : Problem with Querstring


Zoboda
02-12-2005, 12:49 PM
Im having problems with getting information from a querystring when the code Request.Querystring("id" & i), this is in a loop and each time i is increased by 1.

This returns an empty value everytime and Ive tried replacing this with Request.Querstring(id) and having id has "id" & i. And again this isnt working.

Anybody have any ideas on what I can do

chrismartz
02-12-2005, 12:57 PM
what gets outputed and what exactly are you trying to do?

Zoboda
02-12-2005, 01:05 PM
The code is for a page that lets you add or update new menu items. The menu is loaded from a database and I want to be able to change where the pages go by going on the admin panel.
On the menu editing page it loops through every record for the menu and adds the html


<input type="text" name="title<%=menuid%>">


If there are 3 buttons on the menu the querystrin will be
admin.asp?event=menu2&title1=blah&title2=blah&title3=blah
But a code like the one below will output nothing


Do while i < totalitems
response.write(request.Querystring("title" & i))
i = i + 1
Loop


Not sure if that will help, but Im having trouble trying to descibe it

chrismartz
02-12-2005, 01:09 PM
what is totalitems set to?

Zoboda
02-12-2005, 01:14 PM
rsTwo.CursorType = 3
rsTwo.LockType = 2
rsTwo.Open "SELECT id FROM menuitems;", adoCon
totalitems = rsTwo.RecordCount
rsTwo.Close

This isnt ran if there arent any records, so I know that totalitems is at least 1. I just need to know how to use a variable in Request.Querstring(), i thought just putting the variable in called title, and having its value go up like title1, title2, title3, would work

Zoboda
02-12-2005, 01:26 PM
The only way I can think of doing this is by repeating the code

title = Request.Querstring("title1")
followed by entering the data in the db

title = Request.Querstring("title2")
followed by entering the data in the db

title = Request.Querstring("title3")
followed by entering the data in the db

And so on up to about 30, but that seems like a really ugly way to do it, and will also take a long time to load in



edit: Ive sorted it now, instead of being able to edit all the menu items at once I made another page for editting them individually so there is no need to loop through the querstring vars

russell
02-12-2005, 11:09 PM
you could do

For i = 1 to 30
q = "title" & i

title = Request.QueryString(q)
Next
It is also possible that the only thing wrong b4 was you misspelled QueryStringtitle = Request.Querstring("title1")also, in your first post (where QueryString is correctly spelled) you are searching for "id", and your last post you are searching for "title" in the query string...

Zoboda
02-13-2005, 07:15 AM
It wasnt a spelling problem, Im using dreamweaver so its easy to notice where the mistakes are.

I decided to change it so instead of being able to update and all the records at once you click a link to another page that lets you edit the options for that menu button. It works fine this way, would have been easier to use if the script I made at first would have worked