Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
need help with share buttons 11 66
Javascript Regex 7 20
sort Multi-dimensional array 6 9
Javascript: Mouseup doesn't follow mousedown 13 23
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

735 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