用html做自动计算

用html做自动计算,第1张

<!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/htmlcharset=gb2312" />

<title>HTML 自动计算JS Code by Happy</title>

</head>

<body>

<tr>

<td height="12"><div align="center">

<input type="text" id="num1" onkeyup="getTotal()" />

</div></td>

<td height="12"><div align="center">

<input type="text" id="num2" onkeyup="getTotal()" />

</div></td>

</tr>

<tr>

<td height="12"><div align="center">

<input type="text" id="Total" />

</div></td>

</tr>

<script type="text/javascript">

function getTotal(){

var num1 = document.getElementById("num1").value*1

var num2 = document.getElementById("num2").value*1

document.getElementById("Total").value = num1*num2

}

</script>

</body>

</html>

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

</head>

<body>

A:<input type="number" name="" id="a" value="" style="width: 40%height: 50px"/><br />

D:<input type="number" step="0.1" name="" id="d" style="width: 40%height: 50px" value="" min = '0.5' max="0.9" /><br>

<input type="button" name="" id="btn" value="结果" /><br>

<p id="p"></p>

</body>

<script type="text/javascript">

var btn = document.getElementById('btn')

function getC (y){

if(y<10) return alert('错误 y<10')

if(y>=10 &&y<50) return y = 0.2

if(y>=50 &&y<100) return y = 0.3

if(y>=100 &&y<200) return y = 0.4

if(y>=200) return y = 0.5

}

btn.addEventListener('click',function(){

var a = document.getElementById('a').value

var d = document.getElementById('d').value

var b = 1

var y = a*b

var e = 2

var c = getC(y)

var e = 2

var p = document.getElementById('p')

var x = a*d*b*y*e*c*e

p.innerHTML = '你收到了' + a + '元的订单,是' + y + '的完成量,你的提成是' + d + ',计算比例是' + c+ ',则你的计算结果是:' + x+ ',等发工资一起结算。'

})

</script>

</html>

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>cursor test</title>

    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

</head>

<body>

<label>请输入参数1:</label>

<input type="text" id="input1">

<br>

<label>请输入参数2:</label>

<input type="text" id="input2">

<br>

<label>请输入参数3:</label>

<input type="text" id="input3">

<br>

<label>请输入参数4:</label>

<input type="text" id="input4">

<br>

<label>请输入参数5:</label>

<input type="text" id="input5">

<br>

<label>请输入参数6:</label>

<input type="text" id="input6">

<br>

<button>请点击提交查看结果</button>

<br>

<label>结果显示为:</label>

<input type="text" id="result">

<script>

    $(document).ready(function() {

        $("button").click(function(){

            var input1=$("#input1").val()

            var input2=$("#input2").val()

            var input3=$("#input3").val()

            var input4=$("#input4").val()

            var input5=$("#input5").val()

            var input6=$("#input6").val()

            $("#result").attr("value",input1*input2*input3/(input4*input5*input6))

        })

    })

</script>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7667652.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-08
下一篇 2023-04-08

发表评论

登录后才能评论

评论列表(0条)

保存