lenin
Jan 8th, 2001, 04:00 AM
Hi,
I have a script which works fine in IE5, but not in NS4.7. The issue appears to be with assigning values from controls, but I can't seem to get to the bottom of it. I can cycle through the contents of the array, but the script errors out when I assign the selctedItem variable to the listbox control. When I use the forms collection it returns null i.e. instead of formDelivery.delivery.value I tried
document.forms[0].delivery.value - returns null.
Thanks in advance.
Lenin.
<html><head>
<link rel="stylesheet" type="text/css" href="../StyleSheets/Products.css">
</head>
<body topmargin="0" marginheight="0" marginwidth="0" rightmargin="0">
<form id="formDelivery" name="formDelivery">
<br><br><br><br><br><br><br><br><br>
<table width="572">
<tr>
<td width="0%" height="43"></td>
<td valign="top" width="57%" height="43">
<h4>Delivery<br>
<img SRC="../products/images/bar1.jpg" WIDTH="147" HEIGHT="9"> </h4>
</td>
</tr>
<tr>
<td width="0%" height="41"></td>
<td height="41" width="57%"><h5>Choose a company by clicking in the list box below</h5>
<select name="delivery" size="1" onChange="getDetail();">
<option selected value="1">Company A</option>
<option value="12">Company B</option>
<option value="13">Company C</option>
<option value="4">Company D</option>
<option value="5">Company E</option>
<option value="6">Company F</option>
<option value="7">Company G</option>
<option value="8">Company H</option>
<option value="9">Company I</option>
<option value="10">Company J</option>
<option value="11">Company K</option>
</select>
</td>
</tr>
<script Language='JavaScript'>
var DetailArray = new Array();var j = 0;DetailArray[j]= new Array(1,'Customer A Details');j++;DetailArray[j]= new Array(12,'Customer B Details');j++;DetailArray[j]= new Array(13,'Customer C Details');j++;DetailArray[j]= new Array(14,'Customer D Details');j++;
</script>
<script language="JavaScript">
//=========================================================
//
// Compare values in arraywith values in list box, if match populate text area.
//
//==========================================================
function getDetail()
{
var i;
var str
var selctedItem = formDelivery.delivery.value;
// Initialise the text area prior to processing onChange Event for the control
formDelivery.textarea1.value = "";
// Loop through the array for matches with list control values
for(i=0; i < DetailArray.length; i++)
{
// Check each array index for match
if ( selctedItem == DetailArray[i][0]) {
// Populate area if found
formDelivery.textarea1.value = DetailArray[i][1];
}
}
}
</script>
<tr>
<td width="0%" rowspan="2"></td>
<td width="57%"><h4>Company Delivery Details</h4>
<textarea rows="15" cols="50" id="textarea1" name="textarea1">
</textarea>
</td>
<td width="43%" rowspan="2"><img src="../IMAGES/delivery_pics.jpg" width="243" height="347" align="right"></td>
</tr>
<tr>
<td width="57%"> </td>
</tr>
</table>
</form>
</body>
</html>
I have a script which works fine in IE5, but not in NS4.7. The issue appears to be with assigning values from controls, but I can't seem to get to the bottom of it. I can cycle through the contents of the array, but the script errors out when I assign the selctedItem variable to the listbox control. When I use the forms collection it returns null i.e. instead of formDelivery.delivery.value I tried
document.forms[0].delivery.value - returns null.
Thanks in advance.
Lenin.
<html><head>
<link rel="stylesheet" type="text/css" href="../StyleSheets/Products.css">
</head>
<body topmargin="0" marginheight="0" marginwidth="0" rightmargin="0">
<form id="formDelivery" name="formDelivery">
<br><br><br><br><br><br><br><br><br>
<table width="572">
<tr>
<td width="0%" height="43"></td>
<td valign="top" width="57%" height="43">
<h4>Delivery<br>
<img SRC="../products/images/bar1.jpg" WIDTH="147" HEIGHT="9"> </h4>
</td>
</tr>
<tr>
<td width="0%" height="41"></td>
<td height="41" width="57%"><h5>Choose a company by clicking in the list box below</h5>
<select name="delivery" size="1" onChange="getDetail();">
<option selected value="1">Company A</option>
<option value="12">Company B</option>
<option value="13">Company C</option>
<option value="4">Company D</option>
<option value="5">Company E</option>
<option value="6">Company F</option>
<option value="7">Company G</option>
<option value="8">Company H</option>
<option value="9">Company I</option>
<option value="10">Company J</option>
<option value="11">Company K</option>
</select>
</td>
</tr>
<script Language='JavaScript'>
var DetailArray = new Array();var j = 0;DetailArray[j]= new Array(1,'Customer A Details');j++;DetailArray[j]= new Array(12,'Customer B Details');j++;DetailArray[j]= new Array(13,'Customer C Details');j++;DetailArray[j]= new Array(14,'Customer D Details');j++;
</script>
<script language="JavaScript">
//=========================================================
//
// Compare values in arraywith values in list box, if match populate text area.
//
//==========================================================
function getDetail()
{
var i;
var str
var selctedItem = formDelivery.delivery.value;
// Initialise the text area prior to processing onChange Event for the control
formDelivery.textarea1.value = "";
// Loop through the array for matches with list control values
for(i=0; i < DetailArray.length; i++)
{
// Check each array index for match
if ( selctedItem == DetailArray[i][0]) {
// Populate area if found
formDelivery.textarea1.value = DetailArray[i][1];
}
}
}
</script>
<tr>
<td width="0%" rowspan="2"></td>
<td width="57%"><h4>Company Delivery Details</h4>
<textarea rows="15" cols="50" id="textarea1" name="textarea1">
</textarea>
</td>
<td width="43%" rowspan="2"><img src="../IMAGES/delivery_pics.jpg" width="243" height="347" align="right"></td>
</tr>
<tr>
<td width="57%"> </td>
</tr>
</table>
</form>
</body>
</html>