SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One window controls another

    I have a pop-up window that is part of a Web-based WYSIWYG editor that I am trying to make some modifications to. I added a button to this window that opens another pop-up window. What I would like is that when an item is clicked on this second window, it would change the value of the input on the first window.

    Normally when I do something like this, I use a bit of script like:
    Code:
    <a onclick="opener.window.document.MyForm.txtFileName.value='test123'">Click Here</a>
    The only problem here is that the original window does not have a form tag around the inputs. If I add one, it causes an error. If I remove the form part of the reference in the second window, I get an error that txtFileName is NULL or not an object.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give the control an id (same as its name) and use opener.document.getElementById(). The hierarchial form of referencing (DOM 0) requires a - erm - hierarchy , involving the form object.

    btw: opener.window is redundant.
    ::: certified wild guess :::

  3. #3
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I updated my link as
    Code:
    onclick="opener.document.getElementByID('txtFileName').value='test123'"
    Pop-up javascript error: Object doesn't support this property or method
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    getElementById
    ::: certified wild guess :::

  5. #5
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I swear, if I were any dumber it would be a wonder I could turn on my computer
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •