PDA

Click to See Complete Forum and Search --> : get the querystring?


da_silvy
Sep 18th, 2000, 03:56 AM
how do i get the querystring?
http://www.mysite.com/site.asp?Hello

i want the query string to return "hello"

Ianpbaker
Sep 18th, 2000, 05:47 AM
Hi da_silvy

in the url you need http://www.mysite.com/site.asp?sometext=Hello

and in the asp page all you need is

myvar = Request.QueryString("sometext")

Hope this helps

Ian

da_silvy
Sep 19th, 2000, 02:59 AM
thanks

da_silvy
Sep 19th, 2000, 03:38 AM
is there a web site which lists objects and methods for asp?

Ianpbaker
Sep 19th, 2000, 03:40 AM
http://www.4guysfromrolla.com is a very good asp site

da_silvy
Sep 19th, 2000, 03:55 AM
i'm a beginner
i tried this code

<%
Dim myVar
myVar = Request.QueryString("name")
Reponse.Write(myvar)
%>


and it stuffed up, it says internal server error???

Ianpbaker
Sep 19th, 2000, 04:02 AM
There'snothing wrong with that code, I think you have a problem with your server

da_silvy
Sep 19th, 2000, 04:06 AM
how do i retrieve the date?

do you know?

da_silvy
Sep 19th, 2000, 04:09 AM
what host do you use, if any?

da_silvy
Sep 19th, 2000, 04:10 AM
yes, the server has something wrong with it,

it wouldn't even work for :

<%
Reponse.Write("heloi")
%>


so what host do you use?

Ianpbaker
Sep 19th, 2000, 04:13 AM
I don't do any ASP at home I only do it at work, and we have are own servers. what host are you using?. Install PWS from the win98 CD and try running your code locally first, before uploading it

Ian

Ianpbaker
Sep 19th, 2000, 04:14 AM
as for the date, to get the date from the server use now(), the same as in VB

da_silvy
Sep 19th, 2000, 04:21 AM
thankyou very much, does interdev do anything?

Ianpbaker
Sep 19th, 2000, 04:24 AM
the latest version, 6, is a very good development tool for all scripting languages and is my tool of choice for ASP and javascript

glad I could help

Ian

da_silvy
Sep 19th, 2000, 04:57 AM
so am i, i installed pws, and my asp page worked! yay! :)

da_silvy
Sep 19th, 2000, 05:00 AM
is there a way that i can keep updating the current time?

Ianpbaker
Sep 19th, 2000, 06:00 AM
you need a java applet for that, there are 100's around

da_silvy
Sep 20th, 2000, 04:10 AM
ok, thank you (yet again)

gsc1ugs
Dec 5th, 2000, 08:20 AM
Seems like your the man for this one

How can i get each value in a request.querystring... thats a big query string though

main.asp?success=1&REPORT_INFO:USER=user1&REPORT_INFO:SERVICE=access&REPORT_INFO:SERVICE=Access&REPORT_INFO:PRICE_COUNTRYID=1 &REPORT_INFO:PRICE_CURRENCY=None&REPORT_INFO:RENTAL_PERIOD=1&ACCESSPRICEINPUT:CUSTSITE:0=""&ACCESSPRICEINPUT:CUSTTELCODE:0="" &ACCESSPRICEINPUT:CUSTCITY:0=""&ACCESSPRICEINPUT:CUSTDISTRICT:0=""&ACCESSPRICEINPUT:CUSTPOSTCODE:0="" &ACCESSPRICEINPUT:CUSTSTREET:0=""&ACCESSPRICEINPUT:DESTSITE:0=""&ACCESSPRICEINPUT:TARIFFTERM:0=0 &ACCESSPRICEOUTPUT:CUSTSITE:0=Site&ACCESSPRICEOUTPUT:DESTSITE:0=Munchen&ACCESSPRICEOUTPUT:DISTANCE:0=323.22198486328125 &ACCESSPRICEOUTPUT:TARCONNECT:0=3792.97509765625&ACCESSPRICEOUTPUT:TARIFF:0=2.048M E1 Intl&ACCESSPRICEOUTPUT:TARRENTAL:0=12487.5576171875 &ACCESSPRICEOUTPUT:CUSTSITE:1=TOTAL&ACCESSPRICEOUTPUT:DESTSITE:1=""&ACCESSPRICEOUTPUT:DISTANCE:1=323.22198486328125 &ACCESSPRICEOUTPUT:TARCONNECT:1=3792.97509765625&ACCESSPRICEOUTPUT:TARIFF:1=""&ACCESSPRICEOUTPUT:TARRENTAL:1=12487.5576171875


told you..

Many thanks

da_silvy
Dec 6th, 2000, 01:07 AM
does that work?

Ianpbaker
Dec 6th, 2000, 02:42 AM
it did the last time I used it

gsc1ugs
Dec 6th, 2000, 04:52 AM
Cant spcuify each param becuase each param changes.

here's what some kind person sent
Private Function results()
dim i
Dim strURL
Dim strQueryString
Dim varNameValuePairs
Dim varSplitPair
Dim intIndex
Dim strHTML

' Sample URL below - use your super long string value below instead.
strURL = Request.QueryString

' Get QueryString from URL.
strQueryString = Mid(strURL, Instr(1, strURL, "?") + 1)
' Split the QueryString into an array of Name/Value pairs.
varNameValuePairs = Split(strQueryString, "&")
strHTML = strHTML & "<TABLE BORDER=""0"">" & vbcrlf
For intIndex = LBound(varNameValuePairs) To UBound(varNameValuePairs)
' Split Name/Value pair into seperate values.
varSplitPair = Split(varNameValuePairs(intIndex), "=")
strHTML = strHTML & "<TR>"
strHTML = strHTML & "<TD>" & varSplitPair(0) & "</TD>"
strHTML = strHTML & "<TD>=</TD>"
strHTML = strHTML & "<TD>" & varSplitPair(1) & "</TD>"
strHTML = strHTML & "</TR>" & vbcrlf
Next
strHTML = strHTML & "</TABLE>" & vbcrlf

Response.Write strHTML
end Function

gsc1ugs
Dec 6th, 2000, 04:57 AM
So is it possible to have a save button at the bottom of the page should ther user wish to save results??

Cheers

Ianpbaker
Dec 6th, 2000, 05:02 AM
where you say they can change each time you can use the following code to get at all of them and do what you want with them

<HTML>
<body>
<%
Dim params
Dim item

Set params = Request.QueryString

For each item in params
'Replace this code with what ever you need to do with iy
Response.Write item & " " & params(item) & "<BR>"
Next
%>
</BODY>
</HTML>

gsc1ugs
Dec 6th, 2000, 05:12 AM
How could i save the posted results from the htm page.
Many Thanks

Ianpbaker
Dec 6th, 2000, 05:17 AM
Do you mean,to save all those variables to a file or a database for example. by the way I would use the way I show'd you for getting the information as it is a lot more tidy. (sorry, I didn't see your earlier posts_

Ian

gsc1ugs
Dec 6th, 2000, 05:23 AM
Not a database though, must go to users h/drive as .htm file. Is there a simple way to do this?

Many thanks

Ianpbaker
Dec 6th, 2000, 05:25 AM
right, got you. bear with me for a little while and i'll nock something up for you.

Ian

gsc1ugs
Dec 6th, 2000, 05:27 AM
WEY HEY many thanks

Ianpbaker
Dec 6th, 2000, 05:56 AM
Right I;ve done it but their is a slight problem. I can only save it on the server, not on the local machine. what you need to do is find a way to copy it from the server to the local machine, and unfortunatley I dont't know how to do that.

ok on with the show. this first page show's what the user want's to save and has the button at the bottom with the ability to save the query string in a HTML Format.



<HTML>
<body>
<%
Dim params
Dim item
Dim strQueryString

'Get the querystring as it is
strQueryString = Request.QueryString


'Get the query string so you can print it out easily
Set params = Request.QueryString


For each item in params
Response.Write item & " " & params(item) & "<BR>"
Next
%>
<br>
'Pass the query string to save the information
Do you want to save this
<input type="button" onclick="window.location = 'save.asp?<% = strQueryString%>'" value="yes">
</BODY>
</HTML>


then in save.asp put the following code


<%
Dim fs
Dim newhtmpage
Dim Params
Dim Item

' create a new filesystem object
Set fs = CreateObject("Scripting.FileSystemObject")

'create a new file
Set newhtmpage = fs.CreateTextFile("put in where you want so store it onto the server", True)

Set Params = Request.QueryString

'Start off the html file
newhtmpage.WriteLine("<HTML>" & vbNewLine & "<BODY>")

For each Item in Params
'put in the values, you can format this how you like
newhtmpage.WriteLine(Item & " " & Params(Item) & "<BR>")
Next

newhtmpage.WriteLine("</BODY>" & vbNewLine & "</HTML>")
'close the file
newhtmpage.Close


Set fs = Nothing
Set newhtmpage = Nothing
%>
<HTML>
<BODY>
Saved
</BODY>
</HTML>


as I said this will, save it on the server and not on the local machine, but you 50% of the way with this

hope it helps

Ian

gsc1ugs
Dec 6th, 2000, 06:13 AM
If i'm debugging locally ie:pws with Visual InterDEV AND BACK OFFICE where is the file actually being stored.

Cheers

Ianpbaker
Dec 6th, 2000, 06:19 AM
on the line


Set newhtmpage = fs.CreateTextFile("put in where you want so store it onto the server", True) is where you specify where you want the file to be saved.

You I think you need to use winsock to transfer the file to the remote pc, but I know nowt about that although their are quite a few guys that do and should be able to help you.

gsc1ugs
Dec 6th, 2000, 06:57 AM
I just added c:\place\results.htm and it worked.. many thanks
Gary

Ianpbaker
Dec 6th, 2000, 07:03 AM
no worries - glad I could help, but sorry I can't help with the second part