0

Hello guys i would like to know how to retrieve the value of 47 in this url by jquery so that i can use this value to display the specific records associated with the id

...../Rate.aspx#/HotelMobileBooking/Room.aspx?RT=47
ThiefMaster
  • 298,938
  • 77
  • 579
  • 623

3 Answers3

1

Simply use a regular expression for it. /Room\.aspx\?RT=(\d+)/ does the job:

> /Room\.aspx\?RT=(\d+)/.exec('/Rate.aspx#/HotelMobileBooking/Room.aspx?RT=47')[1]
'47'

If you want to access the value in the current URL, use location.hash to access the #... part of the url.

ThiefMaster
  • 298,938
  • 77
  • 579
  • 623
1

no need to use a regular expression. If RT is the only parameter in your querystring just use split()

url = ".../Rate.aspx#/HotelMobileBooking/Room.aspx?RT=47";
url.split("?RT=")[1]; //47
Fabrizio Calderan
  • 115,126
  • 25
  • 163
  • 167
0

This question tells you how to retrieve a query string value using jQuery: How can I get query string values in JavaScript?

Assuming that the URL you posted is the URL of the page that you are on...

Community
  • 1
  • 1
Fiona - myaccessible.website
  • 14,071
  • 15
  • 78
  • 115