99、对数运算

99、对数运算

脚本说明:

把如下代码加入<body>区域中

<script language="JavaScript">

 

function anylog(form)

{

var a = eval(form.a.value);

var b = eval(form.b.value);

var c = (Math.log(b))/(Math.log(a))

var d = Math.round(1000000*c)/1000000

form.z.value = d

}

</script>

<form>

<table border=3 cellspacing=2 cellpadding=5>

<tr>

<td colspan=2 align=center>log<sub>A</sub>B</td>

</tr>

<tr>

<td align=center><i>A</i></td>

<td align=center><i>B</i></td>

</tr>

<tr>

<td align=center><input type=text name=a size=20></td>

<td align=center><input type=text name=b size=20></td>

</tr>

<tr>

<td align=center><input type=button value="请看答案" onclick="anylog(this.form)"></td>

<td align=center><input type=text name=z size=20></td>

</tr>

</table>

</form>

 

Write a comment

Comments: 0