Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2006
    Thanked 0 Times in 0 Posts

    transfer variable 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
    tit1 sub1
    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

    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
    Senior Coder
    Join Date
    Mar 2005
    Portsmouth UK
    Thanked 513 Times in 500 Posts

    this enters text into the selected textarea

    God Loves You and will never love you less.


    If my post has been useful please donate to http://www.operationsmile.org.uk/


    Posting Permissions

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