#1
  1. No Profile Picture
    El Guapo
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    You have moved into a dark place. It is pitch black. You are likely to be eaten by a grue.
    Posts
    56
    Rep Power
    14

    Question Send javascript text from pop-up to form field in parent window


    Greetings,

    I'm trying to send some text from a pop-up to a form-input text field in another window.

    I have this in the header of the main window:

    Code:
    <script language="JavaScript">
    <!--
    self.name = "index";
    -->
    </script>
    And I want to enter text into the form field named "message" from the pop-up window (based on clicking on an href link in the pop-up).

    Can this be done?

    I'm trying to make a "smilies" pop-up for a message board that will display the smilies (which I've done) but then make the smilies clickable (as they are on this message board, for instance) so that the smiley character text is inputted to the message window.

    -- Jough
    See my PHP in action:
    Poetry Archives
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Atlanta
    Posts
    39
    Rep Power
    14
    I haven't tested this out, but I believe it will work. You should be able to access the form in the parent window this way:
    window.opener.document.form.field.value = "some value"

    Good luck.

    Lucas Alexander
    http://www.alexanderdevelopment.net
  4. #3
  5. No Profile Picture
    El Guapo
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    You have moved into a dark place. It is pitch black. You are likely to be eaten by a grue.
    Posts
    56
    Rep Power
    14
    I'm sorry, I'm rather new to javascript.

    So what would I include in my link?

    Code:
    <a href="window.opener.document.form.field.value
     = javascript: smilie(':)')"><img src="(image link)"></a>
    ??

    I guess I just don't know which of those parts need to be changed (with values) and which need to stay as they are.

    -- Jough

    And I can't seem to add the code without the script parsing it. Grrrr....
    Last edited by jough; August 6th, 2001 at 06:23 PM.
    See my PHP in action:
    Poetry Archives
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    81
    Rep Power
    14
    Your link should look something like:

    <a href="javascript:void(window.opener.document.form.field.value
    = smilie('')")><img src="(image link)"></a>

    The "void" is there because otherwise the browser in your popup will try to navigate to the results of the assignment.
    Robert Dominy
    About Guide for JavaScript
    http://javascript.about.com
    Software Consulting & Development
    http://www.angusog.com
  8. #5
  9. No Profile Picture
    El Guapo
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    You have moved into a dark place. It is pitch black. You are likely to be eaten by a grue.
    Posts
    56
    Rep Power
    14
    Okay, but I still can't get this to work.

    Do I just use the link as is, or do I have to substitute the name of the form, field, etc. And what would I put for "value" then?

    I've pretty much tried and erred as much as I can - trying many different permutations.

    I can make it work in IE but not Netscape or Opera.

    It's just all so frustrating.

    -- Jough
    See my PHP in action:
    Poetry Archives
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    81
    Rep Power
    14
    You'll need to subsititute the following:
    form -> the name of your form (e.g., <form name="myform">, would be "myform")
    field -> the name of your input field (e.g., <input type="text" name="mytextfield"> would be "mytextfield">

    value stays as is.
    Robert Dominy
    About Guide for JavaScript
    http://javascript.about.com
    Software Consulting & Development
    http://www.angusog.com
  12. #7
  13. No Profile Picture
    El Guapo
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    You have moved into a dark place. It is pitch black. You are likely to be eaten by a grue.
    Posts
    56
    Rep Power
    14
    I figured as much (and had tried that before, but without the "void").

    But alas, this doesn't work in any browser. Maybe it's because of all of the includes - the pop-up may not know who its parent is.

    Sigh.

    -- Jough
    See my PHP in action:
    Poetry Archives
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    USA
    Posts
    830
    Rep Power
    14
    Well, as we've all learned, painfully, Netscape Navigator is the single most worthless thing ever unleashed upon the face of the Earth by man (and I don't want to hear any snide remarks about the flowbee or DIVX-- ask yourself, when did those ever cause you this much pain?). I'm all for forming an angry, violent mob to track down the people responsible for this abomination to give them what they so truly deserve. Naturally, the window.opener property, among other features of the JavaScript language, brought to us by Netscape, does not work in the Netscape browser, even though their documentation says it does. If it does, then I'll be damned. Belie dat.

    I motion that we, meaning anyone who reads this thread, hereby form a movement in the web development, and preferably, additionally the web browsing community, to boycott use of any Netscape browsing product from this point forward, to be repealed only if they release a browser which complies with basic standards of common decency. Recruit everyone you know. Give them a copy of Internet Explorer. Help them install it. Help them configure it. Help them banish Netscape Navigator from their system. Netscape is floundering: let us join forces and drive the final nail into it's beckoning coffin.
  16. #9
  17. No Profile Picture
    El Guapo
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    You have moved into a dark place. It is pitch black. You are likely to be eaten by a grue.
    Posts
    56
    Rep Power
    14
    I actually *like* Netscape usually, even though I've been using Opera mostly, now.

    Oh, and window.opener doesn't work in Opera, either.

    Is this an IE only thing, or actually part of the javascript language? Doesn't Sun own javascript?

    -- Jough
    See my PHP in action:
    Poetry Archives
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    USA
    Posts
    830
    Rep Power
    14
    Sun has nothing to do with JavaScript. It was developed by Netscape and originally called LiveScript -- they changed the name to JavaScript to try to cash in on the popularity of Java (developed by Sun).

    It doesn't suprise me that it doesn't work in Opera, nor does it matter -- Opera is a joke, a total non-factor. Why should anyone PAY for a sub-standard browser???

    It is NOT an IE only thing, it is part of the JavaScript standard. In fact, you can read all about how well it works in Navigator in their documentation at http://developer.netscape.com/docs/m...4/contents.htm and http://developer.netscape.com/docs/m...sref/index.htm

IMN logo majestic logo threadwatch logo seochat tools logo