[Javascript] form parameters

Chuck Soper chucks at velofish.com
Wed Apr 20 23:47:52 CDT 2005


Paul,

Thank you for the excellent response.

Chuck

>At 04:15 PM 4/20/2005, Chuck Soper wrote:
>>In my desktop application I allow users submit feedback via a web 
>>page with a form. I do this by launching the default browser, with 
>>a certain URL. My JavaScript question is: how can I send parameters 
>>to the form page?
>>
>>Is it something like this:
>>   www.mywebsite.com/feedback.html?parm1=productName
>>
>>How would I access the value of parm1 from JavaScript?
>>
>>Also, is there a way to pass two parameters?
>
>
>Chuck,
>
>www.mywebsite.com/feedback.html?arg1=val1&arg2=val2&arg3=val3
>
>Here's just one way to retrieve them in javascript:
>
>// split the URL into URI & querystring
>var sURL = new String(document.location.href);
>var aHref = sURL.split("?");
>
>// this leaves the URI in aHref[0] and the querystring in aHref[1]
>
>// get an array of argument/value pairs
>var sQ = new String(aHref[1]);
>var aArgPairs = sQ.split("&");
>
>// this puts each "arg=val" pair into each array element
>
>// parse arg pairs
>for (var iArg=0; iArg < aArgPairs.length; iArg++)
>{
>         var sArgPair = new String(aArgPairs[iArg]);
>         var aArg = sArgPair.split("=");
>
>         // this puts the parameter in aArg[0] and the value in aArg[1]
>}
>
>Paul 
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list