Results 1 to 3 of 3

Thread: value transfer to popup (a mind bender)

  1. #1
    Join Date
    Jul 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default value transfer to popup (a mind bender)

    Sorry if this is a bit long-winded but it seems necessary to outline the scenario as I am not really sure of the correct line of solution here.

    Short version:
    How to get a specific (variable) variable into a popup?
    Possibly from an onClick command.
    Or, have the popup get the value -- from the point of launch?

    The long version:

    I have a Content Management System page-edit interface built with PHP.
    It is dynamically built, splitting the page-data-to-be-edited into 'items'

    <form action= etc. Then,
    Each item has:
    <input type=text ... the title [tit]
    <textarea ... sub-text [sub]
    there are several items
    close with: <input type=submit ...

    As the page builds the two elements are progressively numbered:
    tit0 sub0
    <HR>
    tit1 sub1
    <HR>
    tit2 sub2 ... etc.

    Each item's textarea has a format bar on top -- bold, italic, etc. Pretty standard but...
    each bar is set to insert specifically into that textarea.
    So, I have several js functions following this pattern:

    function inserts$i(format1, format2)
    { insertAtCursor(document.EDITFORM.sub$i, format1 + format2); }
    where $i == the respective textarea number

    One of the format options loads a popup with a table of special characters.
    onClick=\"OpenBrWindow('../script/charmap.htm','sub$i','scrollbars=no, toolbar=no, menubar=no','580','300','true')

    I put the sub$i in there in the hope that I might get it to transfer. It doesn't currently do anything

    Question(s):
    In the pop-up I use:
    function put(a,val) { var insert = window.opener.document.EDITFORM.sub0; insert.value += a + val; }
    to insert the specific character. This works -- but only for the first textarea - sub0.
    >>> How can I transfer the value sub$i from the onClick command into function put(a,val)?

    Ie. end up with: ...document.EDITFORM.sub$i;
    being written in the popup function put(a,val) as:
    ...document.EDITFORM.sub0 or,
    ...document.EDITFORM.sub1 or,
    ...document.EDITFORM.sub2 etc.
    according to which of the format bars launches the popup.

    Or, Is there a way of getting the name of the textarea -- getElementsById(TagName)(Name)? or some such. But, how to know which specific element to target?

    Or, a completely different approach????????? and many more??????

    I hope that this makes sense. It is difficult providing literal code when there are several layers of includes and js calls at work.

    If you have read this far - well done & thanks

  2. #2
    Join Date
    Jul 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am still working on this but seem to be getting no closer.

    patience....

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The value of any variable on the opening page is available on the opened page via the opener object. Let's say you have a variable defined on the opening page:

    Code:
    var blah='Hi!';
    Then once you pop up a window from that page, have a link in the new window:

    HTML Code:
    <a href="#" onclick="alert(opener.blah)return false;">What's Blah?</a>
    If blah on the opener page later becomes something else, it will automatically update on the pop up.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •