Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get Javascript URL parameters

Posted on 2016-10-31
7
Medium Priority
?
108 Views
Last Modified: 2016-11-09
I am using jPList - jQuery Data Grid Controls - http://jplist.com

and I am using the deep linking feature: http://jplist.com/documentation/deep-links

which creates an URL parameter on filter change.

I am getting a parameter like the below...

http://www.domain.com/hardware/printers//hardware/printers/#sort:path~type~order=.title~text~asc|category-checkbox-dropdown:pathGroup=.vutek_mid_range~.vutek_high_volume|range-slider-print-width:prev~next=0~3200

Open in new window


Can you please tell me how I would get the relevant parameter to use within the page?

For example I would like to say...

If  "category-checkbox-dropdown:pathGroup" includes ".vutek_mid_range" return "Yes"?

I would prefer to use php for this, but if not Jquery is fine.
0
Comment
Question by:petewinter
  • 3
  • 3
7 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41866980
I would prefer to use php for this, but if not Jquery is fine.
PHP is server side, jQuery is client side - they are not interchangeable

Where do you want to use this information?  

Please describe a use case.
0
 

Author Comment

by:petewinter
ID: 41867008
Hi Julian

Thanks for the reply and sorry for the confusion.

I will be linking to this parameter from another page. So when the page loads I only want to show a particular block of code if the parameter exists.

So if I was using php I would generally use code like the below...

if ( $_GET['parameter'] == "xxx") { .... }

Open in new window


And something similar for jQuery.

Hope that makes sense?
0
 
LVL 60

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 41867052
Just had a look at your URL again - the data you want is in the hashtag which is not sent to the server so you don't have a PHP option

JavaScript
<script>
function checkFor(key, value)
{
  var parts = window.location.hash.substr(1).split('|');
  for(var i in parts) {
    if (parts[i].indexOf(key) != -1) {
      if (parts[i].indexOf(value) != -1) {
        return true;
      }
    }
  }
  return false;
}
if (checkFor('category-checkbox-dropdown:pathGroup', '.vutek_mid_range')) {
  alert('yes');
}
else {
  alert('no');
}
</script>

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:petewinter
ID: 41867061
Perfect. Many thanks
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41867076
You are welcome.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 41881024
0
 

Author Comment

by:petewinter
ID: 41881065
Many thanks Ray
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question