Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    72
    Thanks
    3
    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
    <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

    arfa

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,536
    Thanks
    3
    Thanked 513 Times in 500 Posts
    http://www.codingforums.com/showthread.php?t=94989

    this enters text into the selected textarea
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    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
    •