Hi,
I have a page that features chocolate recipes.
I wanted to give the ability for visitors to print out INDIVIDUAL recipes contained upon the page.
I thought I had it made by going: a.document.write(document.getElementById('printit').innerHTML);
Of course, this only printed the 1st recipe...no matter which one was selected.
I tried creating an array ("printit1","printit2", ...) but I am afraid I am lost.
Can someone please take a look at my code and tell me how I can have a visitor select an individual recipe to print out?
Thanks sooo much! :)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Chocolate Recipes : Brownies, Cakes, Candy, Cookies, Pies, and Miscellaneous Categories</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" language="javascript">
function go()
{
var a = window. open('','','scrollbars=yes,width=600,height=600');
var printarray = new array ("printit1","printit2");
a.document.open("text/html");
a.document.write('<html><head><style type="text/css">p{text-align:center;font-weight:600;}body{padding:20px;background-color:#ffffff;font-family:verdana,tahoma,sans-serif;font-size:10pt;}ul{margin-top:30px;}</style></head><body style="background-image:none;background-color:#ffffff;">');
a.document.write(document.getElementById('printarray()').innerHTML);
/*a.document.write(document.getElementById('printarray').innerHTML);*/
a.document.write('<p> www.chocolatelover.net</p></body></html>');
a.document.close();
a.print();
}
</script>
<style type="text/css" media="print">
@media print {
.printbutton {
display:none;
}
}
</style>
<style type="text/css" media="screen">
#buttonstyle
{
background-color:#fff0b8;
background-image:url(whitechocbg.gif);
color:#301010;
border:1px ridge #301010;
font-weight:500;
margin-left:inherit;
margin-top:20px;
margin-bottom:3px;
}
hr
{
color:#d2b2a8;
border-bottom:1px solid #d2b2a8;
width:250px;
text-align:left;
margin-left:15%;
margin-top:10px;
}
</style>
<link rel="stylesheet" href="style.css" type="text/css" />
<!--[if lt IE 7]><script src="pngfix.js" type="text/javascript"></script><![endif]-->
</head>
<body>
<div style="padding-bottom:3%;border: 3px ridge #8b4513;">
<div align="center" style="margin-top:10px;"><a name="top"></a>
<script type="text/javascript" language="JavaScript" src="http://www.anrdoezrs.net/placeholder-578035?target=_blank&mouseover=N">
</script>
</div>
<div align="center" style="margin:0 auto; padding-top:15px;">
<img src="choclvr.gif" style="width:443px;height:40px; padding-top:20px;" /> <br />
<img src="swirl.gif" width="359" height="58" align="absbottom" />
</div>
<!--topnav-->
<div id="navcontainer"><a name="brownies"></a>
<ul id="topnav">
<li><a href="index.html">Home</a></li>
<li id ="active"><a href="#brownies" id="current">Brownies</a></li>
<li><a href="#cakes">Cakes</a></li>
<li><a href="#candy">Candy</a></li>
<li><a href="#cookies">Cookies</a></li>
<li><a href="#pies">Pies</a></li>
<li><a href="#various">Various</a></li>
<li><a href="#top">Page Top</a></li>
</ul>
</div>
<h2>Brownies</h2>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit1">
<h3>Basic Brownies</h3>
<!--
<div class="menu" style="float:left;width:15%; padding:0px 0px 0px 0px; border:0px; padding-bottom:5px;">
<p>
<a href="index.html">
<img src="small-kiss.png" width="22" height="22" align="texttop" alt=":-*" border="0" /></a>
<a href="index.html">Home</a>
</p>
<p>
<a href="brownies.html">
<img src="small-kiss.png" width="22" height="22" align="texttop" alt=":-*" border="0" /></a>
<a href="brownies.html">Brownies</a>
</p>
<p>
<a href="cakes.html">
<img src="small-kiss.png" width="22" height="22" align="texttop" alt=":-*" border="0" /></a>
<a href="cakes.html">Cakes</a>
</p>
<p>
<a href="candy.html"><img src="small-kiss.png" width="22" height="22" align="texttop" alt=":-*" border="0" /></a>
<a href="candy.html">Candy</a>
</p>
<p>
<a href="cookies.html"><img src="small-kiss.png" width="22" height="22" alt=":-*" align="texttop" border="0" /></a>
<a href="cookies.html">Cookies</a>
</p>
<p>
<a href="pies.html">
<img src="small-kiss.png" width="22" height="22" align="texttop" alt=":-*" border="0" /></a>
<a href="pies.html">Pies</a> </p>
<p>
<a href="various.html"><img src="small-kiss.png" width="22" height="22" align="texttop" alt=":-*" border="0" /></a>
<a href="various.html">Various</a>
</p>
<p>
<img src="small-kiss.png" width="22" height="22" align="texttop" alt=":-*" />
<a href="links.html">Links</a>
</p>
</div>
-->
<table class="recipes">
<tr>
<td>2 Squares of Chocolate</td>
<td>1/2 Cup of Cake Flour</td>
</tr>
<tr>
<td>3 Eggs</td>
<td>1 Cup Chopped Nuts</td>
</tr>
<tr>
<td>1 Cup Sugar</td>
<td>1/8 Teaspoon Salt (optional)</td>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<center>
1/2 Cup Butter or
Butter Substitute
</center> </td>
</tr>
<tr>
<td colspan="2">
<div align="left">
<ul>
<li>Melt the chocolate
and butter (or butter substitute) over hot water</li>
<li>Beat the egg
yolks until light</li>
<li>Add sugar, chocolate,
salt, and butter and mix thoroughly</li>
<li> Measure and
add sifted flour and nuts</li>
<li> Mix thoroughly</li>
<li>Fold in stiffly-beaten
egg whites</li>
<li> Pour into shallow
well-oiled pan and bake in moderate (375 deg. F.) oven for about 15
minutes</li>
<li>Cut into squares,
cool, and remove from the pan<br />
Makes approx. 8 servings</li>
</ul>
</div> </td>
</tr>
</table>
</div>
<!--topnav-->
<div id="navcontainer"><a name="cakes"></a>
<ul id="topnav">
<li><a href="index.html">Home</a></li>
<li><a href="#brownies">Brownies</a></li>
<li id ="active"><a href="#cakes" id="current">Cakes</a></li>
<li><a href="#candy">Candy</a></li>
<li><a href="#cookies">Cookies</a></li>
<li><a href="#pies">Pies</a></li>
<li><a href="#various">Various</a></li>
<li><a href="#top">Page Top</a></li>
</ul>
</div>
<h2>Cakes</h2>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit2">
<h3>18 Minute Chocolate Cake</h3>
<br />
<table class="recipes">
<tr>
<td>2 cups Flour
</td>
<td>1/4 ts Salt</td>
</tr>
<tr>
<td>4 tb Cocoa</td>
<td>1 cup Cold Water</td>
</tr>
<tr>
<td>1/2 cup Vegetable Oil</td>
<td>1/2 cup Butter</td>
</tr>
<tr>
<td>1/2 cup Buttermilk</td>
<td>2 Eggs</td>
</tr>
<tr>
<td>1 3/4 cups Sugar</td>
<td>1 ts Soda</td>
</tr>
<tr>
<td colspan="2">
<ul>
<li>Combine flour,sugar, salt and cocoa in a large bowl</li>
<li>Mix water, oil and butter in a sauce pan</li>
<li>Bring to a boil</li>
<li>Pour into dry mix and beat until smooth</li>
<li>Add buttermilk, eggs and soda</li>
<li>Beat; batter will be thin</li>
<li>Pour into well greased jelly roll pan</li>
<li>Bake at 350 degrees F until done</li>
<li>Cool on a wire rack; while still
a little warm, frost with your favourite frosting</li>
</ul>
</td>
</tr>
</table>
<hr />
</div>
<br />
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>Black Forest Pudding Cake</h3>
<table class="recipes">
<tr>
<td>1 1/4 cups Sugar<br />
</td>
<td>1 cup Flour</td>
</tr>
<tr>
<td>3 tb Cocoa, unsweetened</td>
<td>2 ts Baking powder</td>
</tr>
<tr>
<td>1/4 ts Salt</td>
<td>1/3 cup Butter, melted</td>
</tr>
<tr>
<td>1/2 cup Packed brown sugar</td>
<td>1 1/2 ts Vanilla</td>
</tr>
<tr>
<td>1/4 cup Cocoa, unsweetened</td>
<td>1 1/4 cup Hot water</td>
</tr>
<tr>
<td>1/4 cup Kirsch or 2 tb. water plus</td>
<td>1/2 ts almond or rum extract</td>
</tr>
<tr>
<td>1 Can cherry pie filling</td>
<td> </td>
</tr>
<tr>
<td colspan="2">Preheat
oven to 350 degrees F. In a medium-size bowl, combine 3/4 cup of the sugar,
flour, three tablespoons of the cocoa, baking powder and salt. Blend in
milk, melted butter and vanilla; beat until smooth. Spread into an 8 inch
square pan. In a small bowl, combine remaining 1/2 cup sugar, brown sugar
and remaining 1/4 cup cocoa; sprinkle mixture evenly over batter. Combine
hot water and kirsch; pour over batter. Do not stir. Bake for 40 minutes,
or until center is almost set. Let stand 15 minutes. Transfer to dessert
dishes and spoon pudding from bottom of pan over cake. Serve with cherry
pie filling as sauce.</td>
</tr>
</table>
<hr />
</div>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>Buttermilk Chocolate Hazelnut Cake</h3>
<table class="recipes">
<tr>
<td>1 cup Buttermilk</td>
<td>1/3 cup Safflower oil</td>
</tr>
<tr>
<td>2 ea Egg whites</td>
<td>1 ts Vanilla extract</td>
</tr>
<tr>
<td>1 cup Light brown sugar</td>
<td>1 cup Whole wheat pastry flour</td>
</tr>
<tr>
<td>1/2 cup Cocoa powder</td>
<td>1 ts Baking soda</td>
</tr>
<tr>
<td>1 ts Baking powder</td>
<td>1/4 ts Salt</td>
</tr>
<tr>
<td>1/2 cup Finely chopped hazelnuts</td>
<td> </td>
</tr>
<tr>
<td colspan="2">Preheat oven to 350 degrees F.
Combine first 5 ingredients in mixing bowl and beat together with electric
mixer. Combine remaining ingredients except the hazelnuts in another bowl.
Sprinkle into the wet mixture a bit at a time and beat in with the mixer
until velvety smooth. Lightly oil 9 in. cake pan. Sprinkle the bottom with
flour. Pour in half of the batter, then sprinkle it evenly with half of
the hazelnuts. Pour in the remaining batter and top with the remaining hazelnuts.
Bake for 25 to 30 min., or until tests clean. Cook, and cut into wedges.
</td>
</tr>
</table>
</div>
<!--topnav-->
<div id="navcontainer"><a name="candy"></a>
<ul id="topnav">
<li><a href="index.html">Home</a></li>
<li><a href="#brownies">Brownies</a></li>
<li id ="active"><a href="#cakes">Cakes</a></li>
<li><a href="#candy" id="current">Candy</a></li>
<li><a href="#cookies">Cookies</a></li>
<li><a href="#pies">Pies</a></li>
<li><a href="#various">Various</a></li>
<li><a href="#top">Page Top</a></li>
</ul>
</div>
<h2>Candy</h2>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>Chocolate Fudge</h3>
<table class="recipes">
<tr>
<td>
<p>2 Cups of Sugar</p>
</td>
<td>
<p>2 Tablespoons of Butter/Butter Substitute</p>
</td>
</tr>
<tr>
<td>
<p>2 Squares of Unsweetened Chocolate or 6
Tablespoons of Cocoa</p>
</td>
<td>
<p>2/3 Cup of Milk</p>
</td>
</tr>
<tr>
<td>
<p>A Few Grains of Salt</p>
</td>
<td>
<p>1 Teaspoon of Vanilla Flavoring</p>
</td>
</tr>
<tr>
<td colspan="2">
<ul>
<li>Combine the sugar, milk, butter, salt,
and grated chocolate or cocoa </li>
<li>Cover mixture until the boiling point
is reached</li>
<li>Boil to "soft ball" stage
of 234-238 deg. F.</li>
<li>Add vanilla flavoring and cool without
stirring to room temperature</li>
<li>Beat until mixture is a creamy, rich,
thick mixture that will hold its shape when dropped from a teaspoon</li>
<li>Drop by teaspoon onto waxed paper, or
pour into well-buttered, shallow pan</li>
<li>Cool, and cut into squares</li>
</ul>
</td>
</tr>
</table>
</div>
<!--topnav-->
<div id="navcontainer"><a name="cookies"></a>
<ul id="topnav">
<li><a href="index.html">Home</a></li>
<li><a href="#brownies">Brownies</a></li>
<li><a href="#cakes">Cakes</a></li>
<li><a href="#candy">Candy</a></li>
<li id="active"><a href="#cookies" id="current">Cookies</a></li>
<li><a href="#pies">Pies</a></li>
<li><a href="#various">Various</a></li>
<li><a href="#top">Page Top</a></li>
</ul>
</div>
<h2> Cookies</h2>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>Baked Chocolate Marshmallow Treats ("S'mores")</h3>
<table class="recipes">
<tr>
<td>6 Graham crackers, halved </td>
<td>6 large marshmallows, halved</td>
</tr>
<tr>
<td>3 Milk chocolate bars</td>
<td> </td>
</tr>
<tr>
<td colspan="2">Preheat
oven to 500 degrees F. Place cracker halves on ungreased cookie sheet. <br />
Top each half with two 1" squares of chocolate. Add marshmallow half
on top of chocolate. Bake until marsmallow roasts, about 2 minutes. <br />
Serve open faced. May also be served "sandwich style" by placing
another half of graham cracker on top.</td>
</tr>
</table>
<hr />
</div>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>Buffalo Chips</h3>
<table class="recipes">
<tr>
<td>1 cup Butter</td>
<td>1 cup Shortening</td>
</tr>
<tr>
<td>2 cups Brown sugar</td>
<td>2 cups Granulated sugar</td>
</tr>
<tr>
<td>4 Eggs</td>
<td>2 ts Vanilla</td>
</tr>
<tr>
<td>4 cups Flour</td>
<td>2 ts Soda</td>
</tr>
<tr>
<td>2 ts Baking powder</td>
<td>2 cups Oats</td>
</tr>
<tr>
<td>2 cups Corn flake cereal</td>
<td>2 cups Chocolate chips</td>
</tr>
<tr>
<td>1 cup Coconut</td>
<td>1 cup Pecans</td>
</tr>
<tr>
<td colspan="2">Melt together butter and shortening.
Cream with brown sugar, granulated sugar, eggs, and vanilla. Sift together
the flour, soda, and baking powder. Add to creamed mixture. Mix in oats,
cereal, chips, coconut and pecans. Drop large spoonful onto cookie sheet.
Bake in 350 degree oven for 15 minutes.</td>
</tr>
</table>
<hr />
</div>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>P'nutty Chocolate Cookies</h3>
<table class="recipes">
<tr>
<td>1 1/2 cups All purpose flour</td>
<td>2/3 cup Cocoa</td>
</tr>
<tr>
<td>1 ts Baking soda</td>
<td>1/2 ts Salt</td>
</tr>
<tr>
<td>3/4 cup Butter, softened</td>
<td>1/4 cup Shortening</td>
</tr>
<tr>
<td>3/4 cup Packed brown sugar</td>
<td>1/2 cup Granulated sugar</td>
</tr>
<tr>
<td>1 Egg</td>
<td>2 ts Vanilla</td>
</tr>
<tr>
<td>2 cups Peanut butter chips</td>
<td>1 cup Chopped peanuts</td>
</tr>
<tr>
<td colspan="2">Stir together flour,
cocoa, baking soda and salt. Cream butter and shortening in large mixer
bowl until light. gradually beat in brown and granulated sugars. Beat in
egg and vanilla. Blend in dry ingredients. Stir in peanut butter chips and
peanuts. Drop spoonfuls of dough, 2 inches apart, onto ungreased cookie
sheets; flatten slightly with back of spoon. Bake in 375F (190C) oven for
7 to 8 minutes. Cool on sheets 1 to 2 minutes; remove from sheets and cool
completely.</td>
</tr>
</table>
</div>
<!--topnav-->
<div id="navcontainer"><a name="pies"></a>
<ul id="topnav">
<li><a href="index.html">Home</a></li>
<li><a href="#brownies">Brownies</a></li>
<li><a href="#cakes">Cakes</a></li>
<li><a href="#candy">Candy</a></li>
<li><a href="#cookies">Cookies</a></li>
<li id="active"><a href="#pies" id="current">Pies</a></li>
<li><a href="#various">Various</a></li>
<li><a href="#top">Page Top</a></li>
</ul>
</div>
<h2>Pies</h2>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>Basic Chocolate Pie</h3>
<table class="recipes">
<tr>
<td> 2 slices enriched white bread, toasted and made into crumbs</td>
<td> 1 env. unflavored gelatin</td>
</tr>
<tr>
<td> Artificial sweetener to equal 6 tsp. sugar, divided</td>
<td> 1/4 tsp. salt, divided</td>
</tr>
<tr>
<td> 2 med. eggs, separated</td>
<td> 2 c. skim milk</td>
</tr>
<tr>
<td>
1 tbsp. chocolate extract </td>
<td> 1/2 tsp. vanilla extract</td>
</tr>
<tr>
<td> 1/2 tsp. imitation butter flavoring</td>
<td> Green and red food coloring</td>
</tr>
<tr>
<td colspan="2">
<ul>
<li>Press crumbs on bottom and sides of 8 inch pie pan</li>
<li> Bake at 350 degrees, 10 minutes, until browned</li>
<li> Cool</li>
<li> Combine gelatin, sweetener to equal 4 teaspoons sugar, mix with milk</li>
<li> Add yolk mixture to gelatin mixture</li>
<li> Cook over low heat, stirring constantly, until gelatin is dissolved</li>
<li> Remove from heat</li>
<li> Stir in extracts, butter flavoring, and food coloring to make mixture chocolate brown</li>
<li> Cool, stirring occasionally</li>
<li> Spoon into crust</li>
<li> Chill until set</li>
<li> Beat egg whites until frothy</li>
<li> Add remaining sweetener and remaining salt</li>
<li> Beat until mixture stands in peaks</li>
<li> Spoon on pie in 4 equal mounds</li>
<li> Broil until meringue is lightly browned</li>
<li> Serve at once or well chilled</li>
</ul>
Makes 2 servings.
</td>
</tr>
</table>
</div>
<!--topnav-->
<div id="navcontainer"><a name="various"></a>
<ul id="topnav">
<li><a href="index.html">Home</a></li>
<li><a href="#brownies">Brownies</a></li>
<li><a href="#cakes">Cakes</a></li>
<li><a href="#candy">Candy</a></li>
<li><a href="#cookies">Cookies</a></li>
<li><a href="#pies">Pies</a></li>
<li id="active"><a href="#various" id="current">Various</a></li>
<li><a href="#top">Page Top</a></li>
</ul>
</div>
<h2>Various</h2>
<p class="buttonstyle"style="width:70%;margin:0 auto;">
<input name="printbutton" type="button" class="buttonstyle" id="buttonstyle" onclick="go();" value="Print Recipe" />
</p>
<div id="printit">
<h3>Ice Cream</h3>
<table class="recipes">
<tr>
<td><font face="Comic Sans MS">4 eggs</font></td>
<td><font face="Comic Sans MS">1 Can of Sweetened Condensed Milk</font></td>
</tr>
<tr>
<td><font face="Comic Sans MS">1 Can of Evaporated Skim Milk</font></td>
<td><font face="Comic Sans MS">2 Teaspoons of Vanilla</font></td>
</tr>
<tr>
<td><font face="Comic Sans MS">1 Tablespoon Flour</font></td>
<td><font face="Comic Sans MS">1/8 of Teaspoon Salt</font></td>
</tr>
<tr>
<td><font face="Comic Sans MS">1/2 Cup of Sugar</font></td>
<td><font face="Comic Sans MS">1 Can of Chocolate Syrup</font></td>
</tr>
<tr>
<td colspan="2">
<center>
<font face="Comic Sans MS"> 1/2 Gallon of Milk </font>
</center> </td>
</tr>
<tr>
<td colspan="2">
<ul>
<li><font face="Comic Sans MS">Beat eggs slightly</font></li>
<li><font face="Comic Sans MS">Add sweetened condensed milk, evaporated
skim milk and vanilla, </font></li>
<li><font face="Comic Sans MS">Mix well</font></li>
<li><font face="Comic Sans MS">Add flour, salt, and sugar and continue
mixing</font></li>
<li><font face="Comic Sans MS">Add chocolate syrup</font></li>
<li><font face="Comic Sans MS">Pour 1/2 of the milk into the freezer canister</font></li>
<li><font face="Comic Sans MS">Add mixture, less remaining milk to freezer
canister</font></li>
<li><font face="Comic Sans MS">Mix well</font></li>
<li><font face="Comic Sans MS">Add the remaining half of the milk to the
canister</font></li>
<li><font face="Comic Sans MS">Follow instructions on ice cream maker
to finish process</font></li>
</ul> </td>
</tr>
</table>
</div>
<p style="width:70%;margin:0 auto; text-align:center;margin-top:30px;"> <img src="chocline.gif" style="width:60px;height:4px;" />
<br />
<img src="chocline.gif" style="width:120px;height:4px;" />
</p>
</div>
</body>
</html>