473,799 Members | 3,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7657
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 = parseWindowLoca tion(window.loc ation.href);
* alert($GET['valname']);
* will show the value of GET
* variable undefined otherwise.
* @param string aLocation
* @author
* Georgi Naumov
* go******@gmail. com
*/
function parseWindowLoca tion(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.goo glegroups.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 = parseWindowLoca tion(window.loc ation.href);
* alert($GET['valname']);
* will show the value of GET
* variable undefined otherwise.
* @param string aLocation
* @author
* Georgi Naumov
* go******@gmail. com
*/
function parseWindowLoca tion(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[decodeURICompon ent(bits[i++])] =
decodeURICompon ent(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
10998
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. http://www.mozilla.org/js/language/js20/rationale/named.html Why I keep getting error with the below code?
1
2529
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
26555
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 regards
2
1125
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 currently runs as a standard application. When the user runs the app they can monitor its progress, review error logs, and change configuration settings. I need to convert this program to run as a service, but would like the user to retain the...
2
1217
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 works fine. (Vice versa) Is there a way to suppress the popup if only 1 of the value is supplied? There by working truly as an OR?
6
9011
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 and was succesfully processed. - The second one - ExportData - should take as an input parameter an integer an return a XML document. I would like to know if it is possible to do something like that. Do I
4
4040
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 FirstName As String
5
1804
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
4431
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 - adding things like ONCLICK='saveCaret(this)' etc. and it also tries to save any text that user could've entered before the button press.
10
2181
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 other doesn't. So the function is like this: void CreateEntities<T, IT>(IList<ITentities){}
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.