pickup variables in URL in simple HTML page and use them in VBscript (ex test.htm?myvar=value)

P

Phil Di Guillielmo

Hi,
I would like to use a simple HTML page with variables in the URL
example :

test.htm?myvar=value

en then use 'myvar' in VBSCRIPT as follows :

<script language="VBScript">
(? ? ? ? )
.......... msgbox myvar (? ? ? )
</script>


Filip
 
J

Joe Fawcett

Phil Di Guillielmo said:
Hi,
I would like to use a simple HTML page with variables in the URL
example :

test.htm?myvar=value

en then use 'myvar' in VBSCRIPT as follows :

<script language="VBScript">
(? ? ? ? )
......... msgbox myvar (? ? ? )
</script>


Filip
Assuming this is client-side then:
msgbox myvar (location.search)

You will have to parse it yourself, I would employ the split function using
'&' to start with and then again using '='.
 
P

Phil Di Guillielmo

Thanks Joe,
since I am not such a expert, the most I can get out of it was :

myUrl = window.document.location.href
msgbox myUrl

can I use some kind of search function (POS, SUBSTR) to cut the URL in
pieces ?
Filip
 
P

Phil Di Guillielmo

OK, Joe
I think I am getting somewhere with
'location.search' and the left, right and instr functions.
Greetz,
Phil
 
H

Hywel Jenkins

Thanks Joe,
since I am not such a expert, the most I can get out of it was :

myUrl = window.document.location.href
msgbox myUrl

can I use some kind of search function (POS, SUBSTR) to cut the URL in
pieces ?

I see you've posted the VBScript groups, but I can't help you with a
VB solution. OTOH, if you could do this with JavaScript, I have this
which may be of use:
http://hyweljenkins.co.uk/programming/js/getnvp.php
 
A

Aaron J. Scott

Gees..... Here it is, extensible too.

<Script language="vbscript">
Function GetParameterFromURI(sVarName)
Dim oTempParamCollection, I, sTempString, sURI_Query
sURI_Query = window.location.search
Set oTempParamCollection = CreateObject("Scripting.Dictionary")
sURI_Query = Split(sURI_Query, "&")
For I = 0 To UBound(sURI_Query)
sTempString = Split(sURI_Query, "=")
If UBound(sTempString) = 1 Then
If oTempParamCollection.KeyExists(sTempString(0)) Then
oTempParamCollection(sTempString(0)) =
oTempParamCollection(sTempString(0)) & ";" & sTempString(1)
Else
oTempParamCollection.Add sTempString(0), sTempString(1)
End If
End If
Next
If oTempParamCollection.KeyExists(sVarName) Then
GetParameterFromURI = oTempParamCollection(sVarName)
End If
</Script>

This Function will return multiple occourances of "variable name" as a
semicolon
delimited list of values in the ordinal order of appearance in the url.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top