RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1785 | Replies: 1
Reply
Join Date: Apr 2006
Posts: 4
Reputation: jagseo is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jagseo jagseo is offline Offline
Newbie Poster

dynamic combo load problems

  #1  
Jul 26th, 2006
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[i].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>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2005
Posts: 716
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 6
Solved Threads: 43
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Master Poster

Re: dynamic combo load problems

  #2  
Jul 26th, 2006
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.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:07 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC