Pass client side js variable into server side jscript

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-04-12T17:56:38Z Indexed on 2010/04/12 18:03 UTC
Read the original article Hit count: 594

How can I get the query string from the browser url using client side js and set it as a variable to use in some server side scripting?

Client side script:

var project = getQueryString("P");

function getQueryString(param) {
    var queryString = window.location.search.substring(1);
    splitQueryString = queryString.split("&");

    for (i=0; i<splitQueryString.length; i++) {
        query = splitQueryString[i].split("=");
        if (query[i] == param) {
        return query[1];
        }
    }

}

Server side script:

response.write ('<td><a href="/index.asp?P=' + project + ">' + obj.BODY[i].NAME + '</a></td>');

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jscript