[Javascript] Extract portion of URL and place in form field

William T. Simmons tsimmons at employmentlawadvisors.com
Sun May 19 21:30:25 CDT 2002


Andrew,
I'm not Phillip, but thanks for posting the straightforward example script.
I've read about those string methods before, but this is the first time I
feel I've really understood them!
Thanks,
Tommy Simmons
Employment Law Advisory Network
www.employmentlawadvisors.com

----- Original Message -----
From: "Andrew Dunn" <andrew at d2k.com.au>
To: <javascript at LaTech.edu>
Sent: Sunday, May 19, 2002 8:40 PM
Subject: [Javascript] Extract portion of URL and place in form field

> Try this (forgive the variable names):
>
> var thestring;
> var otherstring;
> var locofequal;
>
> thestring = window.location.search;
> locofequal = thestring.indexOf("=");
> otherstring = thestring.substring((locofequal + 1),thestring.length);
> alert(otherstring);
>
> -----Original Message-----
> From: Phillp Morgan [mailto:pmorgan at quickpages.net.au]
> Sent: Monday, 20 May 2002 11:51 AM
> To: 'Andrew Dunn'
> Subject: RE: [Javascript] Extract portion of URL and place in form field
> Sensitivity: Confidential
>
> I couldn't agree more.
>
> Unfortunately, I'm under a ittle pressure to get this done for a promo we
> are running, and much as I would love to spend the time learning, I simply
> just don't have the opportunity right now.
>
> But thanks anyway.
>
> phill
>
> > -----Original Message-----
> > From: javascript-admin at LaTech.edu
> > [mailto:javascript-admin at LaTech.edu]On
> > Behalf Of Andrew Dunn
> > Sent: Monday, 20 May 2002 11:19 AM
> > To: 'javascript at LaTech.edu'
> > Subject: RE: [Javascript] Extract portion of URL and place in form
> > field
> > Sensitivity: Confidential
> >
> > If you want to learn you have to do a bit of research.
> >
> > -----Original Message-----
> > From: Phillp Morgan [mailto:pmorgan at quickpages.net.au]
> > Sent: Monday, 20 May 2002 11:40 AM
> > To: javascript at LaTech.edu
> > Subject: RE: [Javascript] Extract portion of URL and place in form
> > field
> > Sensitivity: Confidential
> >
> > Hi Andrew,
> >
> > Thanks for that tip. I was hoping for something a little more
> > verbose.. Like the actual javascript..
> >
> > > -----Original Message-----
> > > From: javascript-admin at LaTech.edu
> > > [mailto:javascript-admin at LaTech.edu]On
> > > Behalf Of Andrew Dunn
> > > Sent: Monday, 20 May 2002 11:03 AM
> > > To: 'javascript at LaTech.edu'
> > > Subject: RE: [Javascript] Extract portion of URL and place in form
> > > field
> > > Sensitivity: Confidential
> > >
> > > Use the location.search property and use a split() funtion or some
> > > other string function that will give you the text after the string.
> > >
> > > -----Original Message-----
> > > From: Phillp Morgan [mailto:pmorgan at quickpages.net.au]
> > > Sent: Monday, 20 May 2002 11:22 AM
> > > To: javascript at latech.edu
> > > Subject: [Javascript] Extract portion of URL and place in form field
> > > Sensitivity: Confidential
> > >
> > > Hi, I would like to grab the text after the '=' and place it in the
> > > form field 'ticket'. This is a form with only one field,
> > the formname
> > > is 'sverify'
> > >
> > > This is the string...
> > http://www.mysite.com/thanks.html?cbreceipt=Z54HKPT7
> >
> > I'm after the Z54HKPT7.
> >
> > How would I do this?
> >
> > Regards,
> >
> > Phillip Morgan
> > Chief Information Offier
> > Quickpages Business Directories





More information about the Javascript mailing list