Hello fellow programmers.
I am trying to write a small .js script as part of a complicated perl script.
[I am a perl programmer, so sorry if the question sounds easy, but I looked up for hours to different examples without any help!]
What i would like to do is to update the value of a text area with the result of some processing (appending some text to it).
Ok I know it can be easily done with:
document.nameform.Text.value += related_text;
The problem is that the text area I want to write into is NOT in the current "document" (i.e. not in the current browser window).
I have the original textarea in one window, and the update button & related_text created in a totally separate window (which is generated as part of the script after various other steps). The function is basically a search which needs to go through a series of steps (like a wizard), output the result in a separate window where the user can still modify it, and then when the user presses the OK final button should bring the final text (which is agreed on) in the ORIGINAL window (from which everything had started).
Now, I know that you can pass variables from one window to another, doing something similar to this example:
function writeConsole(content) {
top.consoleRef=window.open('','myconsole',
'width=350,height=250'
+',menubar=0'
+',toolbar=1'
+',status=0'
+',scrollbars=1'
+',resizable=1')
top.consoleRef.document.writeln(
'<html><head><title>Console</title></head>'
+'<body bgcolor=white onLoad="self.focus()">'
+content
+'</body></html>'
)
top.consoleRef.document.close()
}
But my problem is:
in this example you GENERATE the window in which you then go and write to, so you HAVE the handle for this window (top.consoleRef) to go and write to it afterwards.
What I need to do is to GET an handle for an "existing" window (not generated by the script itself), so I can write to it.
Of the first window (with the textarea to which i want to input results), I CAN GET parameters of as I CAN WRITE to it some Javascript. So I can create names, objects etc.
I tried as an example to put in this first window something like:
window.name="cer";
and then write to the textarea from the second window as:
cer.Text.value += related_text;
but this does get an error (cer not existing).
I assume that from the second window I would need to do a "search" trough all the existing windows and find the one with the specific attribute and then find the handle for it (this is what you would do in c...), but I have no idea of how to do this in Javascript, or if there is any easier way to create a simple communication channel between two windows
Basically I want to pass a string from one window textarea, to a separate window textarea, with the target textarea being in the ORIGINAL window. I.e. I would like to communicate from one window to an existing one (not created within the .js itself; but ALREADY EXISTING; I need to find out the handle for this existing window).
It sounds complicated, but I am sure you JS gurus can help...
[ BTW, I "could" create a newpage addressing to the original URL just to get the handle and then write to this handle, but the original page has many fields and the user might have left the form incomplete while using this function, so relading on a separate window would bring up only empty fields, even if in that case I would have the handle and could write to the textarea in the original window...]
I am trying to write a small .js script as part of a complicated perl script.
[I am a perl programmer, so sorry if the question sounds easy, but I looked up for hours to different examples without any help!]
What i would like to do is to update the value of a text area with the result of some processing (appending some text to it).
Ok I know it can be easily done with:
document.nameform.Text.value += related_text;
The problem is that the text area I want to write into is NOT in the current "document" (i.e. not in the current browser window).
I have the original textarea in one window, and the update button & related_text created in a totally separate window (which is generated as part of the script after various other steps). The function is basically a search which needs to go through a series of steps (like a wizard), output the result in a separate window where the user can still modify it, and then when the user presses the OK final button should bring the final text (which is agreed on) in the ORIGINAL window (from which everything had started).
Now, I know that you can pass variables from one window to another, doing something similar to this example:
function writeConsole(content) {
top.consoleRef=window.open('','myconsole',
'width=350,height=250'
+',menubar=0'
+',toolbar=1'
+',status=0'
+',scrollbars=1'
+',resizable=1')
top.consoleRef.document.writeln(
'<html><head><title>Console</title></head>'
+'<body bgcolor=white onLoad="self.focus()">'
+content
+'</body></html>'
)
top.consoleRef.document.close()
}
But my problem is:
in this example you GENERATE the window in which you then go and write to, so you HAVE the handle for this window (top.consoleRef) to go and write to it afterwards.
What I need to do is to GET an handle for an "existing" window (not generated by the script itself), so I can write to it.
Of the first window (with the textarea to which i want to input results), I CAN GET parameters of as I CAN WRITE to it some Javascript. So I can create names, objects etc.
I tried as an example to put in this first window something like:
window.name="cer";
and then write to the textarea from the second window as:
cer.Text.value += related_text;
but this does get an error (cer not existing).
I assume that from the second window I would need to do a "search" trough all the existing windows and find the one with the specific attribute and then find the handle for it (this is what you would do in c...), but I have no idea of how to do this in Javascript, or if there is any easier way to create a simple communication channel between two windows
Basically I want to pass a string from one window textarea, to a separate window textarea, with the target textarea being in the ORIGINAL window. I.e. I would like to communicate from one window to an existing one (not created within the .js itself; but ALREADY EXISTING; I need to find out the handle for this existing window).
It sounds complicated, but I am sure you JS gurus can help...
[ BTW, I "could" create a newpage addressing to the original URL just to get the handle and then write to this handle, but the original page has many fields and the user might have left the form incomplete while using this function, so relading on a separate window would bring up only empty fields, even if in that case I would have the handle and could write to the textarea in the original window...]