Page 1 of 1

Receiving Parameters

Posted: Thu Dec 17, 2015 8:25 am
by Ajm
Hi,

Is it possible to receive and process url parameters?

For example I would like to preset some controls based on passed parameters something like: -
http://127.0.0.1:9125/SpiderBasic_Compi ... 0&param3=1

Re: Receiving Parameters

Posted: Thu Dec 17, 2015 10:04 am
by Peter
Ajm wrote:Is it possible to receive and process url parameters?
yes:

Code: Select all

EnableExplicit

Define UrlParameter.s
Define CountParams, ParamCounter
Define NameValue.s

! v_urlparameter = location.search.substring(1);

If UrlParameter <> ""
  Debug "UrlParameter: " + UrlParameter
  CountParams = CountString(UrlParameter, "&")
  For ParamCounter = 0 To CountParams
    NameValue = StringField(UrlParameter, ParamCounter + 1, "&")
    Debug "Parametername: " + StringField(NameValue, 1, "=") 
    Debug "Parametervalue: " + StringField(NameValue, 2, "=")
    Debug "------"
  Next
Else
  Debug "No parameters found"
EndIf
Greetings ... Peter

@Fred: i think it's a good idea to use CountProgramParameters() & ProgramParameter() to determine the url-parameter natively.

Re: Receiving Parameters

Posted: Thu Dec 17, 2015 10:20 am
by Ajm
Thank you again Peter it works perfectly.

I agree it would be nice to have the CountProgramParameters() & ProgramParameter() to determine the url-parameter natively.

Re: Receiving Parameters

Posted: Thu Dec 17, 2015 10:48 am
by Fred
True will be a great candidate for CountProgramParameters()/ProgramParameter()

Re: Receiving Parameters

Posted: Mon Aug 24, 2020 8:57 am
by Dirk Geppert
Can POST data also be read in? I receive structured JSON data that I want to transfer to the web form.