monkeytooth Posted July 30, 2008 Share Posted July 30, 2008 No clue here javascript isn't fully my cup of tea.. anywho. I've seen it done, but don't know how to do it myself. I am building a form, and have a couple links within it that pop up windows to help people figure certain questions out if they get stuck. But now I want to make it even more easier. I have 2 Input fields in particular that I want to attempt to populate from the popped up window. I have a standard one line text box that they can choose from a link what they want to put into the field should they choose a predefined answer for it. Then I also have a single select drop down input. With pre-existing answers already in it, but concidering the question for it some people will most likely choose the popup to help get there answer. ANd by clicking on that pop up I want it to select for them from the drop-down. So I guess the question is how? Anyone? Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 31, 2008 Share Posted July 31, 2008 Use the "opener" reference on the window you just opened to get the parent: <a href=# onclick="var testWin = self.open();testWin.document.write('<a href=# onclick="opener.testBox.value=\'test\';self.close();">test</a>');">test</a> Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted July 31, 2008 Author Share Posted July 31, 2008 I havent tryed this yet, but will soon when I get home. But will this take a window that is popped up and when a link is clicked populate a form from the orginal window that created the pop up? Quote Link to comment Share on other sites More sharing options...
lemmin Posted July 31, 2008 Share Posted July 31, 2008 Yep. You can use whatever method you want to show content in the popup. I am writing it with javascript, but you can popup an existing page with the code that uses the "opener" reference. Basically, the only code you need to know is "opener.testBox.value" where testBox is the id of the input box. Of course, if it is in a form, you will have to use "opener.formid.testBox.value" or you can just use document.getElementById("testBox") Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted August 1, 2008 Author Share Posted August 1, 2008 So if i am understanding this right. On my main window that i click the link to create the pop up, where the form resides in the orginal window with the link. I would name the form. Then in the pop up where the links are that I want to populate the form input with. I just use the code you provided just changing the name vaulues in the code to match the name of the form and the input back on the main window? Sorry this is a new concept to me, as far as using external windows for form populating. So I may come across with assinign questions Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 1, 2008 Share Posted August 1, 2008 There are a number of ways to do this. If you could let me see your code I can show you where you would need to put the javascript to work the way you already have yours set up. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.