Question: I have the following encoded URL string in javascript 

```
var querystring = "http%3A%2F%2Fspsrv%3A1361%2FSitePages%2FCountryManagment%2Easpx%3FCountryId%3D1";

```

How can I get the value of `CountryId` from that ?

Answer: 
Reading between the lines here…

> 
> 
> ```
> escapestring = '${field.value}'
> 
> ```
> 
> 

I'm guessing some server-side templating language is filling in the value of `${field.value}` here. First: you should not dynamically generate Javascript on the fly, it would be a much better idea to fetch this HTML snippet via AJAX or such.

Having said this, since your server is dynamically generating Javascript source code here, it needs to take care to produce **syntactically valid code**. Right now you're naïvely pasting a string into another string, without regards to the syntactic requirements of what you're producing. You cannot fix this in Javascript, since the Javascript itself is already invalid. Your templating language needs to properly encode the string to be valid Javascript. How to do that exactly depends on your templating system; here's a PHP example:

```
var html = <?= json_encode($field->value); ?>;

```

JSON encoding here produces valid Javascript literals, which is all you're looking for here.

Also see [The Great Escapism (Or: What You Need To Know To Work With Text Within Text)](http://kunststube.net/escapism/).
use this

```
var escapestring ='<table id="tblUserList"><tbody><tr><td style="padding: 10px;">some test'+"'"+' and "xyz"</td></tr></tbody></table>';

```