Urgent help needed for opener.document object
5 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sarada_Lakhamraju
Posted On:   Tuesday, October 22, 2002 08:01 PM

Hello All, I have a html form in which I have a textbox on the event onFocus on that textbox, a new window pops up with some hyperlinks. on clicking anyone hyperlink, that data will be go into the textbox. I have written the following code for the hyperlinks for the onclick event of anchor tag its onclick="opener.document.formname.textboxname.value='American Type Culture Collection'; return false;" See view source for the code for this hyperlink " American Type Culture Collection " This works fine with all data, but if the data contains a single quote then I have a problem, it gives an error, how can I handle this??    More>>

Hello All,

I have a html form in which I have a textbox on the event onFocus on that textbox, a new window pops up with some hyperlinks. on clicking anyone hyperlink, that data will be go into the textbox.

I have written the following code for the hyperlinks for the onclick event of anchor tag its

onclick="opener.document.formname.textboxname.value='American Type Culture Collection'; return false;"

See view source for the code for this hyperlink


" American Type Culture Collection "

This works fine with all data, but if the data contains a single quote then I have a problem, it gives an error, how can I handle this??

I hope I am clear with my question!!!

Thanks,

Sarada.

   <<Less

Re: Urgent help needed for opener.document object

Posted By:   G_K  
Posted On:   Wednesday, October 23, 2002 12:03 PM

for this problem you can surely use a "" infront of the single quote.
This problem can occur with other special chars too like & > < # + , for those too use "".

Re: Urgent help needed for opener.document object

Posted By:   G_K  
Posted On:   Wednesday, October 23, 2002 12:03 PM

for this problem you can surely use a "" infront of the single quote.
This problem can occur with other special chars too like & > < # + , for those too use "".

Re: Urgent help needed for opener.document object

Posted By:   Firat_Tiryaki  
Posted On:   Wednesday, October 23, 2002 05:39 AM

first of all use self.opener instead of opener.



use double quotes when giving something a string value


object.value="bla bla";



or use escape charecter ('\') for these kind of things.

Re: Urgent help needed for opener.document object

Posted By:   Sujatha_Gopal  
Posted On:   Tuesday, October 22, 2002 10:44 PM

In the above funtion ChangeQuotes u escape the single quotes by back slash




or directly use like this


onclick="opener.document.formname.textboxname.value='American Type \' Culture Collection'; return false;"

Re: Urgent help needed for opener.document object

Posted By:   Sujatha_Gopal  
Posted On:   Tuesday, October 22, 2002 10:34 PM

Use ChangeQuotes function to append the single quotes
and assign the value to the text box




function changequotes(fielname)
{
var value=fielname.value;
len=value.length

var name1="";
for(var i=0; i {
if(value.charAt(i)=="'")
name1=name1+"''"
else
name1=name1+value.charAt(i);
}
fielname.value= name1
}

About | Sitemap | Contact