Solved

passing table values from child window to parent

Posted on 1998-05-07
2
170 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

756 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