Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popupate a popup from parent 2

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
I know how to populate and fire javascript functions in a parent page from a popup; however, how does one do the opposite? I need to open a window and populate form elements in it from the parent. There's a little too much do it through a query string.

Thanks.
 
Yeah, I know how to use opener. I want to target elements on the opened page, not the opener.
 
Hi

Possible. Or maybe this :
Code:
var popup = window.open("page.htm");
[red]function populate()
{[/red]
  popup.document.getElementById("someDiv").innerHTML = "hi";
  popup.document.formName.fieldName.value = "hello";
[red]}
setTimeout('populate()',1000);[/red]
Or maybe this :
Code:
var popup = window.open("page.htm");
[red]function populate()
{
  if (popup.document && popup.document.getElementById("someDiv")) {[/red]
    popup.document.getElementById("someDiv").innerHTML = "hi";
    popup.document.formName.fieldName.value = "hello";
[red]  } else setTimeout('populate()',100);
}
setTimeout('populate()',100);[/red]
Or maybe else. Personally I do not understand at which step has the OP problem.

Feherke.
 
Thanks Adam. I see it's as simple as referencing the window name rather than the generic .opener
 
Hmm.. I'm getting a 'createBKB is undefined'. Does the var declaration have to be outside the function? I'm triggering it with an onclick so if I put the declaration outside the function, it will fire onload.

Code:
function createNewArticle() {
var createKB = window.open('kb_add_article.asp');
setTimeout('populateKB();',5000);
}

function populateKB() {
createKB.document.gteElementById('kb_title').value = 'test';
//create.tinyMCE.execInstanceCommand("desc_description","mceInsertContent",false,'test');	
}
 
oops. Pasted the wrong thing

Code:
function createNewArticle() {
alert('working on this right now');
var createKB = window.open('kb_add_article.asp');
setTimeout('populateKB(createKB);',5000);
}

function populateKB(target) {
target.document.getElementById('kb_title').value = 'test';
//create.tinyMCE.execInstanceCommand("desc_description","mceInsertContent",false,'test');	
}
 
Anyone have a suggestion on how to pop a window and populate some form items? I've run out of things to try. If I move the var declaration out of the function, it will incessantly open windows everytime the page loads.

Thanks.
 
Hi

Code:
[red]var createKB[/red]
function createNewArticle() {
  alert('working on this right now');
  createKB = window.open('kb_add_article.asp'[red],'unique_target_name_here'[/red]);
  setTimeout('populateKB(createKB);',5000);
}

function populateKB(target) {
  target.document.getElementById('kb_title').value = 'test';
  //create.tinyMCE.execInstanceCommand("desc_description","mceInsertContent",false,'test');    
}

Feherke.
 
Excellent. Thank you.

Code:
var createKB
function createNewArticle() {
  alert('working on this right now');
  createKB = window.open('kb_add_article.asp','createKB');
  setTimeout('populateKB();',3000);
}

function populateKB() {
  createKB.document.getElementById('kb_title').value = 'test';
  //create.tinyMCE.execInstanceCommand("desc_description","mceInsertContent",false,'test');    
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top