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

Discussion in 'HTML' started by Phil Di Guillielmo, Jul 23, 2003.

  1. 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
     
    Phil Di Guillielmo, Jul 23, 2003
    #1
    1. Advertising

  2. Phil Di Guillielmo

    Joe Fawcett Guest

    " Phil Di Guillielmo" <> wrote in message
    news:bflmlv$it8$...
    > 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 '='.
    --

    Joe
     
    Joe Fawcett, Jul 23, 2003
    #2
    1. Advertising

  3. 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


    "Joe Fawcett" <> schreef in bericht
    news:...
    > " Phil Di Guillielmo" <> wrote in message
    > news:bflmlv$it8$...
    > > 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 '='.
    > --
    >
    > Joe
    >
    >
     
    Phil Di Guillielmo, Jul 23, 2003
    #3
  4. OK, Joe
    I think I am getting somewhere with
    'location.search' and the left, right and instr functions.
    Greetz,
    Phil

    "Joe Fawcett" <> schreef in bericht
    news:...
    > " Phil Di Guillielmo" <> wrote in message
    > news:bflmlv$it8$...
    > > 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 '='.
    > --
    >
    > Joe
    >
    >
     
    Phil Di Guillielmo, Jul 23, 2003
    #4
  5. " Phil Di Guillielmo" <> wrote in message news:<bflq2e$l0j$>...
    > "Joe Fawcett" <> schreef in bericht
    > news:...
    > > " Phil Di Guillielmo" <> wrote in message
    > > news:bflmlv$it8$...
    > > > 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 '='.


    > 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

    --
    Hywel
     
    Hywel Jenkins, Jul 23, 2003
    #5
  6. Thanks, problems solved !!!
    100% working !
    Filip

    --
    http://users.tijd.com/fiwi


    "Joe Fawcett" <> schreef in bericht
    news:...
    > " Phil Di Guillielmo" <> wrote in message
    > news:bflrj4$it2$...
    > > OK, Joe
    > > I think I am getting somewhere with
    > > 'location.search' and the left, right and instr functions.
    > > Greetz,
    > > Phil
    > >

    > If location.href = http://www.mySite.com/myQuery.htm?name=me&age=40
    > sParams = Split(Mid(window.location.search, 2), "&")
    > sSearchingFor = "Name"
    > bFound = False
    > For iLoop = 0 To UBound(sParams)
    > sData = Split(sParams(iLoop), "=")
    > If UCase(Unescape(sData(0))) = UCase(sSearchingFor) Then
    > MsgBox sData(0) & " = " & Unescape(sData(1)), vbInformation,

    "Parameter
    > found"
    > bFound = True
    > End If
    > Next
    > If bFound = False Then
    > MsgBox "Parameter not found", vbInformation, "Report"
    > End If
    > --
    >
    > Joe
    >
    >
     
    Phil Di Guillielmo, Jul 24, 2003
    #6
  7. 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.
     
    Aaron J. Scott, Aug 27, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anonieko

    HttpHandlers - Learn Them. Use Them.

    Anonieko, Jun 15, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    562
    tdavisjr
    Jun 16, 2006
  2. RF Emmerink

    Meaning of MyVar >> 1

    RF Emmerink, Jul 15, 2003, in forum: C Programming
    Replies:
    4
    Views:
    599
    Peter Shaggy Haywood
    Jul 18, 2003
  3. =?ISO-8859-1?Q?Ricardo_Ar=E1oz?=

    include myVar

    =?ISO-8859-1?Q?Ricardo_Ar=E1oz?=, Sep 9, 2007, in forum: Python
    Replies:
    1
    Views:
    268
    Richard Jones
    Sep 9, 2007
  4. Replies:
    6
    Views:
    186
    Dr.Ruud
    Feb 6, 2007
  5. LargePig

    document.getElementById(myvar) firefox

    LargePig, Nov 22, 2005, in forum: Javascript
    Replies:
    3
    Views:
    162
Loading...

Share This Page