Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now