Solved

passing table values from child window to parent

Posted on 1998-05-07
2
165 Views
Last Modified: 2012-06-21
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
Comment
Question by:jkfox
2 Comments
 
LVL 6

Accepted Solution

by:
Holger101497 earned 100 total points
ID: 1277541
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
 

Author Comment

by:jkfox
ID: 1277542
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now