HI Amit
add() is not supported in some IE browsers.
try with some other names as
add1
( apart from
add()
)
and also for assigning use
=
not
==
use simplified coding as:
function add1() {
var ddlvalue = document.getElementById("ddl1").value;
var up1 = document.getElementById("up1");
if (ddlvalue == '1')
up1.value = '25';
else if (ddlvalue == '2')
up1.value = '48';
else if (ddlvalue == '5')
up1.value = '200';
else if (ddlvalue == '10')
up1.value = '390';
}
<select id="ddl1" onchange="add1()">
<option value="1">11</option>
<option value="2">21</option>
<option value="5">51</option>
<option value="10">101</option>
</select>
<input type="text" id="up1" />
based on the conversation..
this might help you..
this is just the sample , you can start modifying to fulfill your needs.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery.js.js"></script>
<script type="text/javascript">
function calculate() {
var ddlqty = document.getElementById('ddlqty');
var ddlweight = document.getElementById('ddlweight');
var lblup = document.getElementById('lblup');
var lbllp = document.getElementById('lbllp');
lblup.innerText = ddlweight.value;
var qty = parseFloat(ddlqty.value) * parseFloat(ddlweight.value)
lbllp.innerText = qty;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table border="1">
<tr>
<td>QTY</td>
<td>DESCRIPTION</td>
<td>WEIGHT</td>
<td>U/P</td>
<td>L/P</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ddlqty" onchange="calculate();" runat="server">
<asp:ListItem Text="1" />
<asp:ListItem Text="2" />
<asp:ListItem Text="3" />
<asp:ListItem Text="4" />
<asp:ListItem Text="5" />
</asp:DropDownList>
</td>
<td>Cadburry Dairy Milk
</td>
<td>
<asp:DropDownList ID="ddlweight" onchange="calculate();" runat="server">
<asp:ListItem Text="65 gms" Value="55.00" />
<asp:ListItem Text="165 gms" Value="125.00" />
</asp:DropDownList></td>
<td>
<asp:Label ID="lblup" runat="server"></asp:Label></td>
<td>
<asp:Label ID="lbllp" runat="server"></asp:Label></td>
</tr>
</table>
</form>
</body>
</html>
ideas from site : http://www.chennaionlinegrocery.com/grocery/default.asp[
^]