1

Get Values from URL

var acutal_url = HTTP://my_host.com/account/apps/6/dashboard/6;

what i want is

var pattern_url = HTTP://my_host.com/account/apps/<int:app_id>/dashboard/<int:dash_id> ;

I want app_id & dash_id separately from this URL ..

Is it possible using JavaScript?

2 Answers2

2

Try this

var acutal_url = "HTTP://my_host.com/account/apps/6/dashboard/6"
var app_id = acutal_url.substring( acutal_url.indexOf("/apps/") + 6, acutal_url.indexOf("/dashboard/") ); 

var dash_id = acutal_url.substring( acutal_url.indexOf("/dashboard/") + 11 );  
alert(app_id);
alert(dash_id);
gurvinder372
  • 66,980
  • 10
  • 72
  • 94
1

You should use regular expressions, but just in case you want a tool to do it for you, try http://txt2re.com/

Siderite Zackwehdex
  • 6,293
  • 3
  • 30
  • 46