Solved

passing table values from child window to parent

Posted on 1998-05-07
2
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

738 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