Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to send a variable using window.open

Status
Not open for further replies.

trojan800

Programmer
Nov 27, 2001
53
US
I am trying to pass a variable with window.open using the following code... and I am getting nothing. Granted my knowledge with js is limited, so it may or may not be a: something stupid or b: not possible. Any help or ideas are greatly appreciated. Thanks - Rory

function onBtnClientCoy()
{
var clientCode;

clientCode = new String(document.FORM1.clienCode.value);

var strURL = new String ("updateClientCoy.asp?clientID=" + clientCode);

result = window.open( strURL );

return result;
}
 
nothing's happening? no new window?

i noticed you might be missing a "t" here:
clientCode = new String(document.FORM1.clienCode.value);

is the spelling correct?

=========================================================
while (!succeed) try();
-jeff
 
I am retarded and you are correct sir. Thank you soo much! ...I need to slow down.
 
What if clientCode contained non-url characters? For example, a space was in there. It would have to be encoded to %20 before being appended to the command line. Does javascript include a function to perform all such encodings? ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
icrf,

yes:

var s1 = "this is a string";
var s2 = s1.escape();
alert(s2);

=========================================================
while (!succeed) try();
-jeff
 
Documentation says the following aren't escaped: * @ - _ + . /
As it turns out, I only see + not getting escaped, the rest make it through fine. Is there an easy way to do that manually in javasctript? It looks like something easy for a regular expression and some kind of binary packing function (or for a simple case like this, it could be hard-coded). In perl, it could be something like this:
Code:
$symbols = '+';
$string =~ s/([\Q$symbols\E])/'%'.(unpack('C',$1))/ge;
or less general
Code:
$string =~ s/\+/%43/g;
Thanks for your help. ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
you can use regular expressions in js...the replace() function is one of several that accepts them. its usage is: replace(regex, sReplacement);

$string = $string.replace(/+/g, "%43"); =========================================================
while (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top