473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

is it possible GET parameter

MZ
Hello!

I have got URL address like this:

http:\\www.ZZZZ.com?param=10

Is it possible to call and read the GET param parameter value in Javascript?

I mean such code in PHP language:

$_GET["param"]

Kindest regards
Marcin
May 30 '07 #1
4 7634
On May 30, 5:02 pm, "MZ" <marcinzmyslow...@poczta.onet.plwrote:
Hello!

I have got URL address like this:

http:\\www.ZZZZ.com?param=10
That isn't a URL. The slashes are going in the wrong direction.

And please use example.com (or net or org) for examples (unless you're
a representative of KWIKWEB)
Is it possible to call and read the GET param parameter value in Javascript?
You can parse window.location.search. There isn't a built in system
that splits key/value pairs on ampersands and semi-colons and
constructs an object for you.

May 30 '07 #2
Yes.
It is possible. As David Dorward says above you must
parse window.location. If you cannot made this alone
you can use this function.
/**
* This function assumes a url
* or other string as a argument
* and return hash with url-s
* parameters in the type:
* myhash['getparamname'] = getparam val
* usage:
* var $GET = parseWindowLocation(window.location.href);
* alert($GET['valname']);
* will show the value of GET
* variable undefined otherwise.
* @param string aLocation
* @author
* Georgi Naumov
* go******@gmail.com
*/
function parseWindowLocation(aLocation)
{
var re = /[?&]([^=]+)=([^&]+)/g;
var maches = null;
var urlParts = new Array();
maches = aLocation.match(re);
if(maches != null)
{
for(var i=0;i< maches.length;i++)
{
var urlPart = maches[i].split("=");
urlParts[urlPart[0].substr(1)] = urlPart[1];
}
}
return urlParts;
}

Good Luck !

David Dorward :
On May 30, 5:02 pm, "MZ" <marcinzmyslow...@poczta.onet.plwrote:
Hello!

I have got URL address like this:

http:\\www.ZZZZ.com?param=10

That isn't a URL. The slashes are going in the wrong direction.

And please use example.com (or net or org) for examples (unless you're
a representative of KWIKWEB)
Is it possible to call and read the GET param parameter value in Javascript?

You can parse window.location.search. There isn't a built in system
that splits key/value pairs on ampersands and semi-colons and
constructs an object for you.
May 30 '07 #3
K.

Uzytkownik "Georgi Naumov" <go******@gmail.comnapisal w wiadomosci
news:11**********************@u30g2000hsc.googlegr oups.com...
Yes.
It is possible. As David Dorward says above you must
parse window.location. If you cannot made this alone
you can use this function.
/**
* This function assumes a url
* or other string as a argument
* and return hash with url-s
* parameters in the type:
* myhash['getparamname'] = getparam val
* usage:
* var $GET = parseWindowLocation(window.location.href);
* alert($GET['valname']);
* will show the value of GET
* variable undefined otherwise.
* @param string aLocation
* @author
* Georgi Naumov
* go******@gmail.com
*/
function parseWindowLocation(aLocation)
{
var re = /[?&]([^=]+)=([^&]+)/g;
var maches = null;
var urlParts = new Array();
maches = aLocation.match(re);
if(maches != null)
{
for(var i=0;i< maches.length;i++)
{
var urlPart = maches[i].split("=");
urlParts[urlPart[0].substr(1)] = urlPart[1];
}
}
return urlParts;
}

Good Luck !

David Dorward :
>On May 30, 5:02 pm, "MZ" <marcinzmyslow...@poczta.onet.plwrote:
Hello!

I have got URL address like this:

http:\\www.ZZZZ.com?param=10

That isn't a URL. The slashes are going in the wrong direction.

And please use example.com (or net or org) for examples (unless you're
a representative of KWIKWEB)
Is it possible to call and read the GET param parameter value in
Javascript?

You can parse window.location.search. There isn't a built in system
that splits key/value pairs on ampersands and semi-colons and
constructs an object for you.


Hello!

Thank you for your help.
I have tried this one:

http://adamv.com/dev/javascript/querystring

Some guy from Polish javascript newsgroupds helped me with finding it.

Thank you both for help
Marcin from Poland
May 31 '07 #4
On May 31, 6:59 am, Georgi Naumov <gonau...@gmail.comwrote:
Yes.
Please don't top-post, reply below trimmed quotes.
It is possible. As David Dorward says above you must
parse window.location. If you cannot made this alone
you can use this function.
[...]

Try this one, tested in Safari, Firefox and Opera (wrapped for
posting):

function search2obj(){
// Get search string
var s = window.location.search;
var obj = {};

// Return if no values
if (s.length < 2) return obj;

// Remove ?, fix '+' - change to %20
s = s.substring(1).replace(/\+/g,'%20');

// Split into bits
var bits = s.split(/[=&]/);

// Decode & convert to object
for (var i=0, len=bits.length; i<len; i++) {
obj[decodeURIComponent(bits[i++])] =
decodeURIComponent(bits[i]);
}
return obj;
}

report( search2obj() );

// Just for help - show object property/value pairs
function report(obj){
var p, t = [];
for (p in obj){
t.push(p + ': ' + obj[p]);
}
alert(t.join('\n'));
}
May 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Hiroshi Ochi | last post by:
Hello, Is it possible to initialize javascript function parameters (using MSIE 6.0 and above)? According to the link below, it seems possible to do this. ...
1
by: Abdul Mohsin | last post by:
is it possible to get hidden parameter values using window.opener.document.form.parameter.value. I am getting this error " Object not found" Please help Abdul
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
2
by: Lee Schipper | last post by:
Is it possible to create a single .EXE that can be launched either as a service or as a standard application (with configuration screens, status windows, etc...)? I have an existing program that...
2
by: jim Bob | last post by:
Hi, I have a query with the criteria of (!..) Or !.. When I provide the value from qmylist, a second pop up appears waiting for the value from lstResults. If I enter nothing and click ok, it...
6
by: placek | last post by:
Hi all. I would like to create two web services: - The first one - ImportData - should take as an input parameter a XML document and return an integer saying if passed XML document was valid...
4
by: Pritcham | last post by:
Hi all I've got a number of classes already developed (basic entity classes) like the following: Public Class Contact Private _firstname as String Private _age as Integer Public Property...
5
by: patrin | last post by:
Hi All, given the source document: <?xml version="1.0" encoding="UTF-8"?> <root> <child> <test id="1" name="first child"/> </child> <child>
51
by: Paul Gorodyansky | last post by:
Hi, Ran into the following problem while trying to have a code to attach a Virtual Keyboard to any user's form: User clicks a button and my JavaScript changes outerHTML of say <textarea -...
10
by: Vin | last post by:
Hi, I just wanted to check if I am missing something or if what I am looking for isn't possible. I have a function with 2 generic parameter types, one of these occurs in the argument list the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.