使用javascript检查最大和最小的双号 [英] checking Largest and smallest Double number using javascript

查看:97
本文介绍了使用javascript检查最大和最小的双号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前两个文本框中有四个文本框

将有两个双位数字

第三个文本框将显示它们之间最大的双重否/>
和第四个文本框将显示它们之间的最小双数

解决方案

这是你的作业。你应该试试自己。这里的建议。



使用 Parse 函数解析数字。并使用 if 语句与比较运算符 s来查找状态。使用它你可以轻松找到结果。基于此显示适当文本框上的值。是的,这很简单。



需要教育 [ ^ ]

 <   script  >  
函数hi(){
var a = parseInt(document.getElementById(t1)。value);
var b = parseInt(document.getElementById(t2)。value);
if(a> b){
document.getElementById(t3)。value = a;
} else {
document.getElementById(t4)。value = b;
}
}
< / script >
< 输入 类型 = text name = t1 id = t1 value = >
& nbsp;& nbsp;
< 输入 < span class =code-attribute> type = text 名称 = t2 id = t2 value = >
& NBSP;&安培; NBSP;
< 输入 < span class =code-attribute> type = text 名称 = t3 id = t3 value = >
& NBSP;&安培; NBSP;
< 输入 < span class =code-attribute> type = text 名称 = t4 id = t4 value = >
&  & nbsp; < br >
< br > <跨度class =code-keyword>< input 类型 = 按钮 名称 = b id = b value = bcdefg onclick = hi() >


There is four text box
in first two text box there will be two double digit number
the third text box will show the largest double no between them
and the fourth text box will show the smallest double no between them

解决方案

This is your homework. You should try yourself. Here suggestion.

Parse the numbers using Parse function. And use if statement with comparison operators to find the status. Using that you could find the result easily. Based on that display the values on appropriate textboxes. Yeah, it's simple.

Education Needed[^]


<script>
function hi(){
      var a= parseInt(document.getElementById("t1").value);
      var b = parseInt(document.getElementById("t2").value);
    if(a>b){
        document.getElementById("t3").value = a;
    }else{
        document.getElementById("t4").value = b;
    }
  }
</script>
<input type="text" name="t1" id= "t1" value="">
&nbsp;&nbsp;
<input type="text" name="t2" id= "t2" value="">
&nbsp;&nbsp;
<input type="text" name="t3" id= "t3" value="">
&nbsp;&nbsp;
<input type="text" name="t4" id= "t4" value="">
&nbsp;&nbsp;<br>
<br><input type="button" name="b" id="b" value="bcdefg" onclick="hi()">


这篇关于使用javascript检查最大和最小的双号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆