Solved

Get Javascript URL parameters

Posted on 2016-10-31
7
43 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 52

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 52

Accepted Solution

by:
Julian Hansen earned 500 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Closing Comment

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

Expert Comment

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

Expert Comment

by:Ray Paseur
ID: 41881024
0
 

Author Comment

by:petewinter
ID: 41881065
Many thanks Ray
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now