View Full Version : Need querystring hlp

Jun 21st, 2006, 07:31 PM
I know this may be a newbie question but i still keep getting errors on it...

the code i use:

<script type="text/javascript">
function getit(){
function reopn(){

<body onload="getit()">

The function i need is:
How do i send a variable to the sub.domain ex.
a name from a data-list that user can choose from.

im very new to java, but i tried like this and it fails.
window.location.replace("http://sub.domain.se/default.asp?variable=") & name

its probobly very easy or it simple dont work, i given up on myself.
i hope someone is kind enough to give me a hint in the right way.

thx in advance.

Jun 21st, 2006, 07:45 PM
replace is a regular expression string substitution function. Are you sure that's what you want?

Sounds to me like if you're at x.com/file1.php, you want to go to x.com/file.php?x=5&y=6

If so, you want this:

document.location = document.location + "?x=5&y=6";

Obviously you'll want to check for the existence of a ? first so you might be better served with:

document.location = document.location + (document.location.match(/[?]/).length > 0 ? '&' : '?') + "x=5&y=6";

This puts in an ampersand if there's a ? in the current url, and a ? if there isn't.

Jun 21st, 2006, 07:54 PM
your answer wasnt 100% (99,9) :thumbsup:
but u gave me a good push to success..

im real greatful..