...

View Full Version : report for the selected checkboxes



reasr
03-03-2005, 12:18 PM
Hi this is my first post in this site, and i whish you help me
i have the following html page and i need a script that create a window
showing the selected items as a sentence , also with "Print" & "Close" buttons
-----------------------------------------------

<html>

<head>
</head>

<body>

<form method="POST">
Inquiry Details : <br>
<br>
<input type="checkbox" name="shoes" value="ON"> Shoes<br>
<input type="checkbox" name="tshirt" value="ON"> T-shirt</p>
<p><select size="1" name="accessories">
<option selected>Accessories</option>
<option value="Belt">Watch</option>
<option>Blue</option>
</select><br>
</p>
<p><select size="1" name="Glasses">
<option value="Nike">Nike</option>
<option>Reyban</option>
<option value="Police">Police</option>
<option selected>Glasses</option>
</select><br></p>
<p>
<input type="submit" value="Report" name="B1" style="border-style: ridge; border-width: 1"></p>
</form>

</body>

</html>
----------------------


Regards,

Kor
03-03-2005, 01:25 PM
welcome to the forum.

Try this:

in main page


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
var items = new Array()
function popS(f){
var sa=f.accessories.selectedIndex;
var sg=f.Glasses.selectedIndex;
var i=0;
if(f.shoes.checked){items[i]=f.shoes.name;i++}
if(f.tshirt.checked){items[i]=f.tshirt.name;i++}
if(sa>0){items[i]=f.accessories.options[sa].text;i++}
if(sg>0){items[i]=f.Glasses.options[sg].text;}
var popU = window.open('pop.html','newwin','height=200 width=150')

}
</script>
</head>
<body>
<form method="POST">
Inquiry Details : <br>
<br>
<input type="checkbox" name="shoes" value="ON">Shoes<br>
<input type="checkbox" name="tshirt" value="ON"> T-shirt</p>
<p><select size="1" name="accessories">
<option selected>Accessories</option>
<option value="Belt">Watch</option>
<option>Blue</option>
</select><br>
</p>
<p><select size="1" name="Glasses">
<option selected>Glasses</option>
<option value="Nike">Nike</option>
<option>Reyban</option>
<option value="Police">Police</option>
</select><br></p>
<p>
<input name="" type="button" value="Show me the selected" onclick="popS(this.form)">
<input type="submit" value="Report" name="B1" style="border-style: ridge; border-width: 1"></p>
</form>
</body>
</html>


in pop up page (called pop.html):


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
onload=function(){
var root=document.getElementById('content');
for(var j=0;j<opener.items.length;j++){
var oTxt=document.createTextNode(opener.items[j]);
var oBr=document.createElement('br');
root.appendChild(oTxt);root.appendChild(oBr);
}
}
</script>
</head>
<body>
<div id="content"></div><br>
<br>
<input name="" type="button" value="Print" onclick="self.print()"><input name="" type="button" value="Close" onclick="self.close()">
</body>
</html>

reasr
03-05-2005, 06:11 AM
Thank you very much, it is working 100%



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum