View Full Version : transfer variable to popup (a mind bender)

09-09-2006, 01:08 AM
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


09-09-2006, 09:06 AM

this enters text into the selected textarea

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum