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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Using Escape Function

Status
Not open for further replies.

tokuzumi

Programmer
Sep 16, 2002
40
US
I have a page, where some of the text will be a clickable link, that brings up a popup window. When the user clicks on the link, and the popup window opens, all the values from the text boxes are brought into the page, via the querystring. To get the value of the box in question, I use this method "fieldname=form.fieldname.value", which works just fine, except if users enter a % or a # sign, in which case, the % just disappears, and the # doesn't show anything entered AFTER the # sign. Here is the function I use to popup the window:

var detailsWindow;

function NewWindow(URL, varwidth, varheight)
{
//var w=0,h=0
var width=varwidth, height=varheight;

//ReplaceChars(URL)
//detailsWindow = window.open(URL,'none','width='+width+',height='+height+'');
detailsWindow = window.open(URL,'none','width='+width+',height='+height+',top=0,left=0,scrollbars=yes');

return false;
}

and in the HTML, to call this, I use this for the text, describing the text field:

onclick="NewWindow('updateudfdetail.asp?category=1&Field1='+form.Field1.value+'&Field2='+form3.Field2.value+'',300,600);"

Here is a little something I tried to come up with, using the Escape() function. It doesn't give any errors, but when I click on the link, and it brings up the popup window, it takes me to a page that does not exist, as the URL is undefined.

function ReplaceChars(Link)
{
var Link;
//var URL2;

//for (i = 0; i > URL.length; i++) {
// if (URL.search("#"))
Link = Link.replace("%",escape("%"));
Link = Link + Link.replace("#",escape("#"))
// }

//URL2 = URL.replace("#",escape("#"))
}

If someone could help me out, I'd be much appreciative. I'm a novice JavaScript user. Even the novices call me a novice. Thanks.
 
I forgot to mention...I removed the place I call the ReplaceChars() function. I put it in this line of the NewWindow() function:

detailsWindow = window.open(ReplaceChars(URL)),'none','width='+width+',height='+height+',top=0,left=0,scrollbars=yes');

I even tried replacing URL with Link but it still gives me the undefined url.
 
Hi
Here is one quick way that should work using your original link.

onclick="NewWindow('updateudfdetail.asp?category=1&Field1='+escape(form.Field1.value)+'&Field2='+escape(form3.Field2.value)+'',300,600);" Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
HellTell,

That looks like it is going to do the trick. Thank you very much. I should have had a V8.
 
Cool, let us know if it doesn't Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top