[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

passing table values from child window to parent

While a user is filling in form info, I would like to display the selection choices for the text field
 in a secondary window. Then when the user 'click's on a value from the table of the secondary
window, the value is passed back to the parent window, and  copied into the parent form's
 input text field. I have read about passing values from one form to another,but need a
 detailed example of how this would apply from window to window. Does anyone know
how this could be done in javascript?  thanks
0
jkfox
Asked:
jkfox
1 Solution
 
Holger101497Commented:
Do you really mean two "windows"? you can not open "stay-on-top" windows from JavaScript, so your second window would hardly be visible... I suggest using a second "FRAME" at the top of the page...

anyway... for two windows, it would look like this:

<HTML>
<script>
function displayChoices(tf) {
  chWin=window.open('','choices','height=130,width=125,menubar=no,statusbar=no');
     // this opens a new window... assign a ref. to a frame if you decide to go with a frame
  with (chWin.document) {
    write("<HTML><HEAD><TITLE>Your choices</TITLE></HEAD>");
    write("<BODY>Your choices for "+tf.name+" are:<BR>");
    write("<form name=choiceform><SELECT SIZE=1 onchange='opener.document." +tf.form.name+"." +tf.name+".value= this.options[this.selectedIndex].text;'>");
    if (tf.name=="color") write("<option>yellow<option>red<option>blue<option>black");
    if (tf.name=="size") write("<option>small<option>medium<option>large");
    write("</select></form></BODY></HTML>");
    close();
  }
  chWin.focus(); // bring to front
}
</script>

<BODY>
  <FORM name=myform>
    <INPUT TYPE=text name=color length=10 onfocus="displayChoices(this)"><BR>
    <INPUT TYPE=size name=size length=10 onfocus="displayChoices(this)"><BR>
  </FORM>
</BODY>
</HTML>

note that "opener" refers to the window that opened the current window... writing this to the "new window", it refers to the "main window"
You might also need to insert a timer to check if the "new window" should get the focus, i.e. be sent to the front...

Good luck and let me know if everything works for you!
0
 
jkfoxAuthor Commented:
This answer is a close resolution, however, I will need to open another .html in the window.open function call, this .html will use sql techniques to retreive data from the database and display the data choices within a table. Also, in the example provided above, the 'close();' statement is not really closing the new window. any other ideas?

thanks
jkfox

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now