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
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
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.
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
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...