Solved

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

Posted on 1997-07-16
2
488 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
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: 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

Suggested Solutions

Title # Comments Views Activity
Add or delete table rows 10 53
Copying table data to one another 15 29
Can anyone see what is the fault in my javascript code? 8 28
send email part1 9 24
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

839 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