I have a textarea in a php page, and I would like to have a button next to this textarea that pops up a window. Inside this window the user will type in some information, and I would like to pass this information(after the script formats it) to the textarea(without erasing the info already in the textarea).
Is this possible?
It would be very useful for making links, if the user could just enter the link information and this script could make the a href tag for them.
Thanks.
Updating a textbox from a popup window?
Moderator: General Moderators
if a window is opened due to the action of another window the object opener is a reference to the opening window.
The (maybe) tricky part is to propagate the target-object to the new window.
Maybe a little overkill -but hey- it's mainly a php-board
tested with IE6 and phoenix 0.4
The (maybe) tricky part is to propagate the target-object to the new window.
Maybe a little overkill -but hey- it's mainly a php-board
Code: Select all
<?php
if (isset($_GETї'mode']) && $_GETї'mode'] == 'inputWindow')
{
?><html><head><script language="JavaScript">
function writeBack()
{
oSource = document.getElementById("inputField");
oTarget = opener.document.getElementById("<?php echo $_GETї'target'] ?>");
oTarget.value += oSource.value;
self.close();
}
</script></head><body>
<input id="inputField" />
<button onClick="writeBack();">done.</button>
</body></html><?php
}
else
{
?><html><head><script langeuage="JavaScript">
function createPopup(sTargetId)
{
window.open("<?php echo $_SERVERї'PHP_SELF']; ?>?mode=inputWindow&target="+sTargetId,"inputWindow","width=310,height=150,left=50,top=50");
}
</script></head><body>
<form >
<textarea id="ta1">default</textarea>
<button OnClick="createPopup('ta1');">enter new text</button>
</form>
</body></html>
<?php } ?>