Solved

Get Javascript URL parameters

Posted on 2016-10-31
7
28 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 51

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 51

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Closing Comment

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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 how to look for a specific file type in a local or remote server directory using PHP.

706 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

12 Experts available now in Live!

Get 1:1 Help Now