interpim Posted June 22, 2007 Share Posted June 22, 2007 Hello all, I want to start with the fact I have Very Little knowledge of javascript but am willing to learn. What I am trying to do I think requires javascript, but I don't know how to implement it. Basically, I have a phpbb that I run. I am trying to create a plug-in that will allow my forum users to click a link when they are writing a post that when clicked will pull up a pop-up window. The pop-up will process an upload of an image via PHP, but the thing I want it to do is when that form is submitted, I want the image path/name of the uploaded image to be put into the forum text field with the bbcode tags around it automatically. This is to basically make picture posting dummy proof for my users. Any recommendations are appreciated. Link to comment https://forums.phpfreaks.com/topic/56670-solved-fill-a-form-field-from-a-different-window/ Share on other sites More sharing options...
tarun Posted June 24, 2007 Share Posted June 24, 2007 page1.html <SCRIPT LANGUAGE="JavaScript"> <!-- function openChild(file,window) { childWindow=open(file,window,'resizable=no,width=200,height=400'); if (childWindow.opener == null) childWindow.opener = self; } //--> </SCRIPT> <FORM NAME="parentForm"> <INPUT TYPE="button" VALUE="Open child" onClick="openChild ('page2.html','win2')"> <BR><INPUT NAME="pf1" TYPE="TEXT" VALUE=""> <BR><INPUT NAME="pf2" TYPE="TEXT" VALUE=""> </FORM> page2.html <SCRIPT LANGUAGE="JavaScript"> <!-- function updateParent() { opener.document.parentForm.pf1.value = document.childForm.cf1.value; opener.document.parentForm.pf2.value = document.childForm.cf2.value; self.close(); return false; } //--> </SCRIPT> <FORM NAME="childForm" onSubmit="return updateParent();"> <BR><INPUT NAME="cf1" TYPE="TEXT" VALUE=""> <BR><INPUT NAME="cf2" TYPE="TEXT" VALUE=""> <BR><INPUT TYPE="SUBMIT" VALUE="Update parent"> </FORM> Works Like A Charm Just Try It Out An Example Is Also Available: Here Link to comment https://forums.phpfreaks.com/topic/56670-solved-fill-a-form-field-from-a-different-window/#findComment-281510 Share on other sites More sharing options...
interpim Posted June 25, 2007 Author Share Posted June 25, 2007 Ok... that does work... but, it also erases anything that exists in the form already. What i want to do is leave any text the user has typed still in the box, but add the link which I will create with PHP inside bbcode for images. For instance... I'm typing a reply on a forum. I want to add a picture. I click the link at the bottom of the form, it opens a popup with an upload dialog. The user searches for the image, clicks upload, and once the upload is complete. The path to the image is returned to the original form where the users cursor was when they were typing. Leaving everything that they had typed out already. Is this possible with Javascript? Or do I have to pass that text somehow? Link to comment https://forums.phpfreaks.com/topic/56670-solved-fill-a-form-field-from-a-different-window/#findComment-282185 Share on other sites More sharing options...
tarun Posted June 25, 2007 Share Posted June 25, 2007 Page 1 <SCRIPT LANGUAGE="JavaScript"> <!-- function openChild(file,window) { childWindow=open(file,window,'resizable=no,width=200,height=400'); if (childWindow.opener == null) childWindow.opener = self; } //--> </SCRIPT> <FORM NAME="parentForm"> <INPUT TYPE="button" VALUE="Open child" onClick="openChild ('page2.html','win2')"> <BR><INPUT NAME="pf1" TYPE="TEXT" VALUE=""> <BR><INPUT NAME="pf2" TYPE="TEXT" VALUE=""> </FORM> Page 2 <SCRIPT LANGUAGE="JavaScript"> <!-- function updateParent() { opener.document.parentForm.pf1.value = opener.document.parentForm.pf1.value + document.childForm.cf1.value; opener.document.parentForm.pf2.value = opener.document.parentForm.pf2.value + document.childForm.cf2.value; self.close(); return false; } //--> </SCRIPT> <FORM NAME="childForm" onSubmit="return updateParent();"> <BR><INPUT NAME="cf1" TYPE="TEXT" VALUE=""> <BR><INPUT NAME="cf2" TYPE="TEXT" VALUE=""> <BR><INPUT TYPE="SUBMIT" VALUE="Update parent"> </FORM> That Should Do It Just Test It And Play Around With It Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/56670-solved-fill-a-form-field-from-a-different-window/#findComment-282196 Share on other sites More sharing options...
interpim Posted June 26, 2007 Author Share Posted June 26, 2007 Thanks for your help... I'll toy around with it to get it to do what I want... I appreciate your help. Link to comment https://forums.phpfreaks.com/topic/56670-solved-fill-a-form-field-from-a-different-window/#findComment-282803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.