Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 29th, 2003, 04:03 PM
Registered User
 
Join Date: Aug 2003
Location: Monument, Colorado, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to wjenkins
Default How to post data to window opener

Hi;
I've got a window in a frame that opens another window when a choice is selected in a select list. This new window gathers some information and then is supposed to post it back to a specific field on the window that opened this window in the first place. But the javascript to post the data back to the opener doesn't work. The line that is having the problem is this:

opener.document.form.getElementById("MenuExtraChg["+Index+"]").value=99.9;

(I've hard-coded the number and for simplicity.)
I've also tried reading from the parent form in a similar manner and that doesn't work either:

myVal = opener.document.form.getElementById("MenuExtraChg["+Index+"]").value;

Help please!
Reply With Quote
  #2 (permalink)  
Old August 30th, 2003, 10:54 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can you show the actual lines of code as what you posted here looks ok in theory?

--

Joe
Reply With Quote
  #3 (permalink)  
Old August 30th, 2003, 11:13 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

The getElementById method just belongs to the document, and is not a method of the form object. Remove the form. to have your code look like this:

Code:
myVal = opener.document.getElementById("MenuExtraChg["+Index+"]").value;
Does that help??

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #4 (permalink)  
Old August 30th, 2003, 03:40 PM
Registered User
 
Join Date: Aug 2003
Location: Monument, Colorado, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to wjenkins
Default

Thank you so VERY much! That worked beautifully!:D

Since you seem to be a helpful sort, I have one other little problem...

In my parent form, I have an array of textareas that I can't seem to access from javascript. Here's what I have (doesn't work):

document.getElementById(\"MenuItemComment[\"+MenuIndex+\]\").value=\"Nothing Entered\";\n";

I need to also access the same field from the child screen.
Thanks for your help so far!


Reply With Quote
  #5 (permalink)  
Old August 30th, 2003, 03:49 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Helpful sort?? Hmmm, not sure whether that is good or not.... ;)

Anyway, below you'll find an example that builds an array of textareas on the page and then loops through it alerting each value of the area. Notice that it isn't very cross browser as it uses getElementById and getElementsByTagName.....

Cheers,

Imar

Code:
<html>
    <head>
        <title>Array of Text Areas</title>
        <script language="JavaScript">
            function OnLoad()
            {
                var allTextAreas;
                // get a reference to all <textarea> tags in the page
                if (document.all || document.getElementsByTagName) 
                {
                    allTextAreas = document.getElementsByTagName("textarea");
                }
                else 
                {
                    document.write("Unrecognized Browser Detected");
                }
                // If there are textareas
                if (allTextAreas.length > 0)
                {
                    for (i = 0; i < allTextAreas.length; i++)
                    {
                        alert(document.getElementById(allTextAreas[i].id).value);
                    }
                }
            }
        </script>
    </head>
<body onload="OnLoad();">
<textarea id="txt1">Text 1</textarea>
<textarea id="txt2">Text 2</textarea>
<textarea id="txt3">Text 3</textarea>
</body>
</html>
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener for mozilla jun99 Javascript 3 September 1st, 2009 08:57 AM
Problem accessing the window.opener.opener maryuob Javascript 3 January 18th, 2006 05:25 AM
can you get window.opener data in server side code edmicman Javascript 3 August 27th, 2005 03:41 AM
window.opener help fs22 Javascript How-To 6 May 9th, 2004 10:50 PM



All times are GMT -4. The time now is 01:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.