Welcome to Dream.In.Code
Become an Expert!

Join 149,614 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,862 people online right now. Registration is fast and FREE... Join Now!




Copy/Paste Textbox Content to Window.opener

 
Reply to this topicStart new topic

Copy/Paste Textbox Content to Window.opener

jenglish
21 Aug, 2007 - 06:31 PM
Post #1

New D.I.C Head
*

Joined: 21 Aug, 2007
Posts: 1


My Contributions
By clicking a form button I need to copy content from Question_textarea to a specific textarea within window.opener page. Below is a little code from the page containing Question_textarea. Please note if this is possible it must be done WITHOUT refreshing or reloading window.opener as it has a timer running and this can't be reset. I will be glad to share the link to this problem.

Any help is GREATLY appreciated!

CODE


<script>
function copyTA(f) {
for (var i = 1; i<arguments.length; i+=2)
    f.elements[arguments[i+1]].value = f.elements[arguments[i]].value;
}
</script>

</head>

<body>
<form>
<textarea name="Question_textarea" cols="30" rows="3" id="Question_textarea" ><cfoutput>#rsQuestion_id_que.question_que#</cfoutput></textarea>

<input name="button" type="button" onclick="Window.opener.location.form.Question_textarea" value="click here." />
</form>
</body>


User is offlineProfile CardPM
+Quote Post

GWatt
RE: Copy/Paste Textbox Content To Window.opener
21 Aug, 2007 - 06:57 PM
Post #2

human inside
Group Icon

Joined: 1 Dec, 2005
Posts: 2,356



Thanked: 31 times
Dream Kudos: 500
My Contributions
This isn't a java question. I suggest you check out the HTML/CSS/Javascript forum
User is offlineProfile CardPM
+Quote Post

alpha02
RE: Copy/Paste Textbox Content To Window.opener
21 Aug, 2007 - 09:40 PM
Post #3

D.I.C Addict
Group Icon

Joined: 20 May, 2006
Posts: 687


Dream Kudos: 850
My Contributions
Moderators, move to HTML/CSS/JavaScript smile.gif

So, I'd suggest you use:

CODE
someform.sometextarea.value = opener.form.textarea.value;


Hope this helps.

This post has been edited by alpha02: 21 Aug, 2007 - 09:41 PM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Copy/Paste Textbox Content To Window.opener
21 Aug, 2007 - 09:43 PM
Post #4

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Like GWatt said, this question belongs in the Javascript forum not the Java forum. They are two different things. Having said that, here is your solution that you were looking for. Below is the javascript you include in the page that has been opened (the popup)...

CODE

<script language="javascript">
function copyarea() {
    var area = document.getElementById("Question_textarea");
    window.opener.openertextarea.value = area.value;
}
</script>
</head>

<body>
<form>
<textarea name="Question_textarea" cols="30" rows="3" id="Question_textarea" ><cfoutput>#rsQuestion_id_que.question_que#</cfoutput></textarea>

<input name="button" type="button" onclick="copyarea()" value="click here." />
</form>
</body>
</html>


Things to note here are the call of a javascript function from the button. In the function we get a reference to the textarea element on the current page, and then through the window.opener reference, we reference the other window and its textarea element called "openertextarea."

We then simply dump the value from this page's textarea into the value of the other textarea on the opener page.

Simple as that! ph34r.gif

Enjoy!

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:29AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month