Javascript Dropdownbox

Posted by edgar on Stack Overflow See other posts from Stack Overflow or by edgar
Published on 2010-03-08T17:45:25Z Indexed on 2010/03/08 17:51 UTC
Read the original article Hit count: 442

I have a dropdownbox (percent), a input box(price) and a input box (total) When you select a percent from the dropdown, it multiplies the value of the selected dropdown times the price value and input the result in the total input box. This works well with one input box, but what I am trying to do is to use asp and when you select a percent from the drop down box, it will calcualate the rest of the total fields.

Here is the code that I have so far
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% Dim Recordset1 Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_pricdsn_STRING
Recordset1.Source = "SELECT * FROM AMFLIB.MBCWCPP where cwfvnb = 1090101 and cwaitx between '0025' and '0025AT'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!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>

Javascript Untitled Document

<script type="text/javascript">
function startCalc4(){
  interval = setInterval("calc4()",1);
}
function calc4(){
  one = document.form1.prcbook.value;
  two = document.form1.percent.value; 
  document.form1.total.value = (one * 1) * (two * 1);
}
function stopCalc4(){
  clearInterval(interval);
}
</script>
<style type="text/css">
<!--
#Layer1 {
 position:absolute;
 left:26px;
 top:49px;
 width:150px;
 height:24px;
 z-index:1;
}
#Layer2 {
 position:absolute;
 left:36px;
 top:22px;
 width:166px;
 height:22px;
 z-index:2;
}
#Layer3 {
 position:absolute;
 left:19px;
 top:24px;
 width:174px;
 height:21px;
 z-index:3;
}
-->
</style>


 <script type="text/javascript">
function showhideText(box,id)  {  var elm = document.getElementById(id)  elm.style.display = box.checked? "inline":"none" }
</script>

</head>

<body>



<form id="form1" name="form1" method="post" action="">
  <p>
  </p>


  <p>&nbsp;</p>
    <p>
      <input type="text" name="itm" value="<%=(Recordset1.Fields.Item("CWAITX").Value)%>"/>


      <select name="percent" onFocus="startCalc4();"onBlur="stopCalc4();">        
   <option value="0">select</option>        
   <option value="1.10">10%</option>
   <option value="1.25">25%</option>  </select>
  </p>
    <p>
      <% If Not REcordset1.EOF Then 
  Do while not REcordset1.EOF %>
      <input type="text" name="qty" value="<%=(Recordset1.Fields.Item("CWAJQT").Value)%>"onfocus="startCalc4();" onblur="stopCalc4();"/>
      <input name="prcbook" type="text" value="<%=(Recordset1.Fields.Item("CWKDVA").Value)%>"onfocus="startCalc4();" onblur="stopCalc4();"/>
      <input type="text" name="total" value=""/>
    </p>
    </form>
</body>
</html>
<%
      REcordset1.MoveNext
  Loop
End If
%>

© Stack Overflow or respective owner

Related posts about javascript-events

Related posts about JavaScript