<html>
<head>
<script language=javascript>
function updateopen()
{
var c_value = "";
var cb = document.getres.checkbox;
    for (var i=0; i < cb.length ; i++)
   {
   if (document.getres.checkbox[i].checked)
      {
      c_value = c_value + document.getres.checkbox[i].value + "\n";
      }
   }
alert(c_value);
//window.opener.document.getElementbyId(numbe33).value = c_value
//window.close();
}
</script>
</head>
<body>
<?
echo '<form name="getres" id="getres">
<p align=center><table border=1 cellpadding=3 cellspacing=0><tr>
		<th width=100px valign=bottom nowrap>
		<font face=arial size=3><br> Item Number</font></th>
		<th colspan=2 widht=200px valign=bottom nowrap><font face=arial size=3><br> Item Name </font></th></tr>';

for ($g=0;$g < sizeof($a); $g++)
{
echo '<tr><td align=middle name=number[] id=number nowrap><font size=2>'.$a[$g].'&nbsp;</font></td>';
echo '<td align=middle name=itname[] id=itname nowrap><font size=2>'.$b[$g].'&nbsp;</font></td>';
echo '<td><input type=checkbox name=checkbox[] value='.$a[$g].'></td></tr>';
}
echo '</table><br>';
echo '<input type=button value=go onClick="updateopen()"></p>';

echo '</form></body></html>';
}
   include('Spec_dbclose.i');
?>

it gives me "cb is undefined" error dont know what is wrong ?????????

Here is a new function that actually loops through the checkboxes:

function updateopen() {
	var c_value = "";
	var cb = document.getres.checkbox;
	
	for (var i=0; i < document.getres.length ; i++) {
		if (document.myForm[i].type=="checkbox" && document.getres.checkbox[i].checked) {
			c_value += document.getres.checkbox[i].value + "\n";
		};
	};
	
	alert(c_value);
	//window.opener.document.getElementbyId(numbe33).value = c_value
	//window.close();
}
<html>
<head>
<script language=javascript>
function updateopen()
{
var c_value = "";
var cb = document.getres.checkbox;
    for (var i=0; i < cb.length ; i++)
   {
   if (document.getres.checkbox[i].checked)
      {
      c_value = c_value + document.getres.checkbox[i].value + "\n";
      }
   }
alert(c_value);
//window.opener.document.getElementbyId(numbe33).value = c_value
//window.close();
}
</script>
</head>
<body>
<?
echo '<form name="getres" id="getres">
<p align=center><table border=1 cellpadding=3 cellspacing=0><tr>
		<th width=100px valign=bottom nowrap>
		<font face=arial size=3><br> Item Number</font></th>
		<th colspan=2 widht=200px valign=bottom nowrap><font face=arial size=3><br> Item Name </font></th></tr>';

for ($g=0;$g < sizeof($a); $g++)
{
echo '<tr><td align=middle name=number[] id=number nowrap><font size=2>'.$a[$g].'&nbsp;</font></td>';
echo '<td align=middle name=itname[] id=itname nowrap><font size=2>'.$b[$g].'&nbsp;</font></td>';
echo '<td><input type=checkbox name=checkbox[] value='.$a[$g].'></td></tr>';
}
echo '</table><br>';
echo '<input type=button value=go onClick="updateopen()"></p>';

echo '</form></body></html>';
}
   include('Spec_dbclose.i');
?>

it gives me "cb is undefined" error dont know what is wrong ?????????

"cb is undefined"

Your problem is document.getres.checkbox is not giving you a list of checkboxes.
Instead I suggest you to loop through the rows of of the <Table> where you have placed your chekcboxes.
What you have to do
Assign an ID to the TABLE (<TABLE id = "holder">)

and below is your updated function:

function updateopen()
{
var c_value = "";
var cb = document.getElementsByName('checkbox'); 
var tbl = document.getElementById("holder");//This will get u the Table
var tbody = tbl.childNodes[0];//This will get u the TBODY tag
var rows = tbody.childNodes;//This will get u the list of all the Rows in the TABLE
//alert(tbl.childNodes[0].tagName); 

    //for (var i=0; i < cb.length ; i++)
	for (var i=1; i < rows.length ; i++)//We start from i=1 not 0 because the first row dows not contain checkboxes
   {
  // if (document.getres.checkbox[i].checked)
  if(rows[i].childNodes[2].childNodes[0].checked)
      {
      //c_value = c_value + document.getres.checkbox[i].value + "\n";
      c_value = c_value + rows[i].childNodes[2].childNodes[0].value + "\n";
	  }
   }
alert(c_value);
//window.opener.document.getElementbyId(numbe33).value = c_value
//window.close();
}

Regards ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.