[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Javascript questions

nuwan@telecheck.com wrote:
> I am trying to allow the user to enter data using another window. I open this
> new window in a function in my main html file. Then I use write method to
> create a form inside that new window plus a 'OK' button. On the onClick
> event of ok button I want to call a validate function that is defined in that
> file. When I load the html file I get a form in a seperate window but when I
> click on the ok button I get a javascript error saying validate function is
> not defined. May be that the validate function is not visible in the new
> window. Does anybody in this list know any solutions for this ?
> Thanks
> - Nuwan

When you say "...a validate function that is defined in that file." are you referring to 
your "main" html file or to an HTML file which you load into your new window when it's 
created?  If it's the latter, then that file is getting overwritten when you create the 
form in the new window using the write method. As far as I know there is know way to append 
to an existing document.

You have a couple of options. You can actually write the javascript for the validate 
function into the new window using the write method. This way the validate function will 
exist in the same document as the OK button and everything should be fine. But this is 

Your second option is to define the validate function in your main html file, and then when 
you're writing to the new window you can actually write a line which declares and 
initializes a window varible to point BACK to your main window. This way the validate 
function SHOULD be available to your secondary window through the window ID of your main 
window. I have not tried this exactly, but I've done some similar things with talking 
between windows. Any problems with this?

-- Robert

Robert Thuleen
Sr. Software Engineer
Science Applications International Corp (SAIC)
San Diego, Ca