日期:2014-05-18  浏览次数:20718 次

关于将添加的数据进行除法运算
我刚开始学ASP,很多不懂,希望各位指教。
我做了一个添加页面,其中有一列是比率需要做除法运算,单位是%。
那如何实现,在添加数据的过程,让他自动做除法运算了。
例如下面的例子在什么地方加如代码实现:
<table   width= "20% "   border= "1 "   cellpadding= "0 ">
    <tr>  
        <td   width= "42% "> 操作数1 </td>
        <td   width= "32% "> 操作数2 </td>
        <td   width= "26% "> 比率 </td>
    </tr>
    <tr>
        <td   width= "42% "> <input   type= "text "   name= "c1 "   size= "12 "> </td>
        <td   width= "32% "> <input   type= "text "   name= "c2 "   size= "12 "> </td>
        <td   width= "26% "> <input   type= "text "   name= "c3 "   size= "12 "> </td>
    </tr>
</table>
如何让C3等与c1除以c2的值
谢谢

------解决方案--------------------
好难,想了半天,应该用script做,但是想不到方法,偶也学习学习
------解决方案--------------------
lz可以将表单提交后在另一页面计算。

<%@ page contentType= "text/html; charset=GBK "%>
<%@ page import= "java.util.*,bookstore.*; "%>
<html>
<head>
<title> TestBookDBean2 </title>
</head>
<body bgcolor= "#ffffff ">
<table width= "20% " border= "1 " cellpadding= "0 ">
<tr>
<td width= "42% ">
操作数1
</td>
<td width= "32% ">
操作数2
</td>
</tr>
<tr>
<form action= "a.jsp " method= "get ">
<td width= "42% ">
<input type= "text " name= "c1 " size= "12 ">
</td>
<td width= "32% ">
<input type= "text " name= "c2 " size= "12 ">
</td>
<input type= "submit " value= "提交 " />
</form>
</tr>
</table>
</body>
</html>


********************************

<%@ page language= "java " import= "java.util.* " pageEncoding= "GBK "%>
<html>
<head>
<title> </title>
</head>
<body>
<%
float c1 = Float.parseFloat(request.getParameter( "c1 "));
float c2 = Float.parseFloat(request.getParameter( "c2 "));
out.println( "比率: "+(c1 / c2 * 100)+ "% ");
%>
</body>
</html>