Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Passing parameters to a new page
- From: paul at juniperwebcraft.com (Paul Novitski)
- Subject: [Javascript] Passing parameters to a new page
- Date: Wed May 16 10:36:58 2007
At 5/16/2007 07:40 AM, Del Wegener wrote: >On my algebra website I have a button labed QUIZ at several location on each >of many pages. Each of these locations has a NAME. The intent is that >clicking on this button takes me to a new page which presents an interactive >quiz on the material associated with the location of the particular button >that was clicked. > >Is there any way for me to pass NAME to the new page ? I would like to >avoid server-side programming like PERL or PHP. If your form is a GET type the form values will be revealed in the querystring of the next page. You can parse document.location, first splitting on "?" to isolate the querystring, then splitting on "&" to isolate name/value pairs, and finally splitting on "=" to get the individual values. 0) http://example.com/?name=XXX&AAA=BBB 1) name=XXX&AAA=BBB 2) name=XXX AAA=BBB 3) name XXX DOM:document.location http://developer.mozilla.org/en/docs/DOM:document.location Core JavaScript 1.5 Reference:Global Objects:String:split http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:String:split Or if you were seeking just that one value you could use a regular expression such as: /[?&]name=[^&=]+(&|$)/i / begin regular expression [?&] question mark or ampersand name= "name=" [^&=]* zero or more characters except ampersand and equals (&|$) ampersand or end of string / end regular expression i case-insensitive The javascript method match would then capture XXXX in these circumstances: http://example.com/?name=XXX http://example.com/?name=XXX&AAA=BBB http://example.com/?AAA=BBB&name=XXX http://example.com/?AAA=BBB&name=XXX&CCC=DDD http://example.com/?NaMe=XXX etc. Core JavaScript 1.5 Guide:Regular Expressions http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Regular_Expressions Regards, Paul __________________________ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com
- References:
- [Javascript] Passing parameters to a new page
- From: Del Wegener
- [Javascript] Passing parameters to a new page
- Prev by Date: [Javascript] Passing parameters to a new page
- Next by Date: [Javascript] Passing parameters to a new page
- Previous by thread: [Javascript] Passing parameters to a new page
- Next by thread: [Javascript] Passing parameters to a new page
- Index(es):