Solved

onclick send form contents to child window bodyonclick send form contents to child window body

Posted on 1997-07-16
2
494 Views
Last Modified: 2010-05-18
My personalized fitness program generator form (so far) looks like this:

<FORM>
Client's Name<INPUT TYPE="TEXT" NAME="name" SIZE=35>
<P>
<INPUT TYPE="CHECKBOX" NAME="exercise" VALUE="<IMG SRC='ex1.gif'>
<BR>blah,blah (ex1)<HR>">EXERCISE 1<BR>

<INPUT TYPE="CHECKBOX" NAME="exercise" VALUE="<IMG SRC='ex2.gif'>
<BR>blah,blah (ex2)<HR>">EXERCISE 2<BR>

<INPUT TYPE="CHECKBOX" NAME="exercise" VALUE="<IMG SRC='ex3.gif'>
<BR>blah,blah (ex3)<HR>">EXERCISE 3<BR>

ETC,ETC...<P>

<INPUT TYPE="reset" NAME="Reset">
</FORM>

What I need is an onclick button (function) which opens a child window and writes the form field contents ('name' and 'exercise') into the BODY of the popped window.  Please help!!My personalized fitness program generator form (so far) looks like this:

<FORM>
Client's Name<INPUT TYPE="TEXT" NAME="name" SIZE=35>
<P>
<INPUT TYPE="CHECKBOX" NAME="exercise" VALUE="<IMG SRC='ex1.gif'>
<BR>blah,blah (ex1)<HR>">EXERCISE 1<BR>

<INPUT TYPE="CHECKBOX" NAME="exercise" VALUE="<IMG SRC='ex2.gif'>
<BR>blah,blah (ex2)<HR>">EXERCISE 2<BR>

<INPUT TYPE="CHECKBOX" NAME="exercise" VALUE="<IMG SRC='ex3.gif'>
<BR>blah,blah (ex3)<HR>">EXERCISE 3<BR>

ETC,ETC...<P>

<INPUT TYPE="reset" NAME="Reset">
</FORM>

What I need is an onclick button (function) which opens a child window and writes the form field contents ('name' and 'exercise') into the BODY of the popped window.  Please help!!
0
Comment
Question by:boatful
[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 7

Accepted Solution

by:
faster earned 100 total points
ID: 1268558
You can use something like the following:


<html>
<head>
<script>
function showit()
{
      window1=window.open('','window1','width=400,height=200');
      window1.document.write("name="+document.form1.name.value+"  exercise=");
      if (document.form1.exercise1.checked)
            window1.document.write(document.form1.exercise1.value+" ");
      if (document.form1.exercise2.checked)
            window1.document.write(document.form1.exercise2.value+" ");
      if (document.form1.exercise3.checked)
            window1.document.write(document.form1.exercise3.value);
      window1.document.close();      
}
</script>
</head>
<body>
<FORM name="form1">
                  Client's Name<INPUT TYPE="TEXT" NAME="name" SIZE=35>

                  <P>
                  <INPUT TYPE="checkbox" NAME="exercise1"
                  VALUE="ex1">EXERCISE 1<BR>

                  <INPUT TYPE="checkbox" NAME="exercise2"
                  VALUE="ex2">EXERCISE 2<BR>

                  <INPUT TYPE="checkbox" NAME="exercise3"
                  VALUE="ex3">EXERCISE 3<BR>

                  ETC,ETC...<P>

                  <INPUT TYPE="button" NAME="test" value="test" OnClick=showit()>
                  <INPUT TYPE="reset" NAME="Reset">
                  </FORM>
</body>
</html>

0
 

Author Comment

by:boatful
ID: 1268559
Thanks, Faster.........
The only concern I have is the 50 or so "if,then" statements I will need........
I wonder, could we replace all the "if (document.form1.exercise1.checked)" statements with a routine such as "for i = 1 to n"
if (document.form1.i.checked)
window1.document.write(document.form1.i.value);

where n is the number of exercises in the menu.

this would shorten the script considerably, I'd think.
Do you care to try??
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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