tags:

views:

26

answers:

1

Hi all, I need to check the value of a particular variable alone from set of variables using JQuery.....

This is my code

 return "{" + string.Format("IsPreviewed:'{0}',PreviewdUrl:'{1}',IsFreeVideo:'{2}'",
                             parameters[12],pranu,jithu) +"}";

The value will be returned to a function in a .Js file for ex: uploader.Js where i will store all these values in a variable.

From this variable i need to check whether the pranu variable contains a value like www.google.com ,jithu variable has a boolean value either true or false using JQuery

Can any one provide some ideas or sample coding to help me solve this task......

+2  A: 

So, if I've understood correctly you just want to pull out the pranu variable from the string?

var foo = "IsPreviewed:'1',PreviewdUrl:'www.google.co.uk',IsFreeVideo:'y'";

var variable = "PreviewdUrl";

// Get the start of the string, add 2 to gnore the preceeding :'
var startIndex = foo.indexOf(variable) + variable.length + 2; 
var endIndex = foo.indexOf(",", startIndex) - 1; // Remove the end '

alert(foo.substring(startIndex, endIndex));

Here's a working example.

GenericTypeTea
NB. There's probably a nicer method using regex.
GenericTypeTea