1

I have a search facility, for example the URL would be something like:-

http://www.website.com/properties/?house_town=&min_price=0&house_type=&max_price=9999999&house_status=Buy&order=desc

What I want to do is create a link, i.e.

<a id="test" href="#">Order ASC</a>

That would update the records on this page on click of the above link, therefore it would need to update the URL to &order=asc which would re-order the listing that is on this page.

At the moment I am doing it as follows:-

jQuery('#test').on('click', function(e) {
    e.originalEvent.currentTarget.href = window.location.href +'?order=DESC';
});

This gets the current URL and adds the value after the URL. The problem is that it keeps addings ?order=DESC?order=DESC every time you click. Also it would be a problem if ?order=DESC was already in the URL.

Any help would be much appreciated!

nsilva
  • 5,184
  • 16
  • 66
  • 108
  • See http://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery. Maybe that's what you're looking for. – hherger Jan 27 '16 at 21:18
  • If you have a table of data that is being displayed, there are tools that will help you sort the data in that table without refresh. Please edit your post and include a bit more detail so that we can better assist. – Twisty Jan 27 '16 at 22:23

0 Answers0