0

I have one string

var str = '';
str += 'category='+jv('category')+'&';

str += 'refresh_rate='+jv('refreshRate')+'&';

str += 'submit=Y';

now I want to take values from jv('category') and jv('refreshRate') in separate string in javascript (I want to extract values after "=" and before "&").

Thanks.

2
  • Question is unclear. What is jv, and where is the category and refreshRate value coming from? Commented Aug 23, 2010 at 6:19
  • jv is like this function jv(divid){if(document.getElementById(divid)) return document.getElementById(divid).value; } Commented Aug 23, 2010 at 6:45

2 Answers 2

0

I've used this: http://blog.stevenlevithan.com/archives/parseuri URI Parser in the past and find it simple to use and it doesn't rely on any other libraries. Its also pretty lightweight.

The author has a demo page but doesn't really explain how to use it.. Its really simple, you just do something like this:

var url = "http://my-site.com:8081/index.html?query=go&page=2";
var parsed = parseUri(url);

From there you can get things like the host/protocol/port/etc.. When dealing with the querystring you do

var page = parsed.queryKey.page;
alert(page); //alerts 2

Click the parse button on the demo page to see all properties of the parsed URI object that you can access..

Sign up to request clarification or add additional context in comments.

Comments

0

You can use http://github.com/allmarkedup/jQuery-URL-Parser or any other URL parser for this sort of string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.