PDA

View Full Version : query string or similar


Bluemonkey
01-23-2003, 03:43 PM
its it possiable to have something similar to query strings in javascript? so i can have a input field on one page that becomes the default value in the next pages input.


thanks for the help

beetle
01-23-2003, 03:48 PM
You mean like this? (http://www.codingforums.com/showthread.php?s=&threadid=11802)

Mhtml
01-23-2003, 03:52 PM
or this? (http://www.codingforums.com/showthread.php?s=&threadid=342&highlight=how+to+use+querystrings)

whammy
01-24-2003, 01:15 AM
Or this?


<script type="text/javascript">
<!--
function queryString(str) {
var q = window.location.search;
var foundValue = "";
if(q.length > 1) {
this.q = q.substring(1,q.length);
this.keyValuePairs = new Array();
for(var i = 0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
if(this.keyValuePairs[i].split("=")[0] == str) {
foundValue = unescape(this.keyValuePairs[i].split("=")[1]);
}
}
}
return foundValue;
}
//-->
</script>


They all do the same thing pretty much (although this one probably isn't quite as efficient and may take a couple more milliseconds), give or take a couple of lines of code...