PDA

View Full Version : javascript Variable Help


BrianMerkel
06-28-2006, 11:51 AM
Hello, I am using the following code to extract the x value of the query string.

----------------------
<head>


<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
alert('Query Variable ' + variable + ' not found');
}
</script>

</head>






<body>
<script>
alert( getQueryVariable("x") );

</script>

-----------------

What i need to do is make it so that i can place the extracted querystring info and use it in this:

document.getElementById ("NameOfDIV").innerHTML = WHAT DO I PUT HERE?

Unfortuantly I do not know what to make the inner.HTML equal to to display the query string.
IF anyone can help, that would be great.
Thank you,
-Brian

RysChwith
06-28-2006, 02:27 PM
document.getElementById( "NameOfDIV" ).innerHTML = getQueryVariable( "x" );As this is a JavaScript question, I'll move it to the client-side forum. Placing questions in the proper forums increases your chances of getting answers.

Rys