hi

i have TWO combo Combo A and Combo B,
Combo A fetch data from database means dynamic values....
now i want that if user select Combo A and select prticular row or index and press ADD button than the selected value should add to Combo B...if user selecte ALL vaulues from Combo A and press ADD button than ALL Combo A values should copy to Combo B...., i am getting javascript error "object is null"
here is my code....

/************************************/

<?
require_once("class/connection.php");

?>

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script>

function a()
{
document.frmsizematrix.s2.remove(0);
}

function add(x)
{

//alert("Value of x is :" + x);
var boxLength;
var selectedItem;
var selectedText;
var selectedValue;
var i;
var thisitem;
var isNew = true;


if ( x == 0)
{

boxLength = document.frmsizematrix.s2.length;
selectedItem = document.frmsizematrix.s1.selectedIndex;
selectedText = document.frmsizematrix.s1.options[selectedItem].text;
selectedValue = document.frmsizematrix.s1.options[selectedItem].value;
}

if ( x == 1)
{
boxLength = document.frmsizematrix.s2.length;
selectedText = document.frmsizematrix.t1.value;
}
//var newoption;
//document.frmsizematrix.t1.value = x;//boxLength;

if (boxLength != 0)
{
for (i = 0; i < boxLength; i++)
{
if ( selectedText == document.frmsizematrix.s2.options.text)
{
isNew = false;
break;
}
}
}

if (isNew == true)
{
document.frmsizematrix.s2.options[boxLength] = new Option(selectedText,boxLength);
}
}

function rmv()
{
var selectedItem;
selectedItem = document.frmsizematrix.s2.selectedIndex;
document.frmsizematrix.s2.remove(selectedItem);
}

</script>

</head>

<body onload="a();">
<form name="frmsizematrix" method="post" action="SizeMatrixprocess.php">
<table width="69%" border="1" cellpadding="1" cellspacing="1" align="center" class="text">
<tr>
<td colspan="2" align="center"><b><font color="#0000FF">Add Width for Selected Item</font></b></td>
</tr>
<tr>
<td>Add Size Style Name :</td>

<td>&nbsp;<input type="text" name="txtSizematrix"></td>
</tr>
<tr>
<td width="25%">&nbsp;Size</td>
<td width="75%"><table width="283" align="center">
<tr>
<td align="center">Available Sizes</td>
<td></td>
<td align="center">Assign Sizes</td>
</tr>
<tr>
<td><?
$sql="select * from tblsizemst";
$rs = mysql_query($sql);
$num = mysql_num_rows($rs);
//echo $sql;
//echo $num;
//$i=0;
?>
<select name="s1[]" size="6" multiple id="select" >
<?
while($row = mysql_fetch_array($rs))
{
$sizeId=$row[0];
$SizeName=$row[1];
echo"<option value=$SizeName>$SizeName</option>";

}

?>
</select> </td>
<td align="center"><input type="button" value="ADD" name="b1" onClick="add(0);">
<br>
<br>
<input type="button" value="Remove" name="b3" onclick="rmv();" /></td>
<td>
<select name="s2" size="6" multiple="multiple">
<option ></option>
</select> </td>
</tr>
<tr> </tr>
</table></td>
</tr>
<?
//}
//End of if condition
?>
<tr>
<td colspan="2" align="center"><input type="submit" name="btnadd" value="Save Size">
&nbsp;<input type="button" value="Cancel" onclick="window.close();" name="button">
</td>
</tr>
</table>
</form>
</body>

</html>

Hi,

This is actually a javascript problem, not php. You'd probably get better help in the js forum. It would also be easier to figure out the problem if you looked at the HTML source instead of the PHP source, as JavaScript is client side and only acts on the HTML source in the browser. (View -> Source).

From the error you are getting: "Object is null", I can guess that you're using Internet Explorer. IE does not really debug JavaScript very well as the error messages are quite meaningless.
You should try using Firefox to debug your JS. The inbuilt JavaScript Console allows you to view the errors in more detail.
Theres also a number of JS debugger extensions yuou can download for firefox.

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.