js厘米与英寸尺码转换
<style type="text/css">
#txt_cm1, #txt_inch1, #txt_inch2, #txt_cm2 {
width: 63px;
height: 26px;
margin: 0 5px;
border: solid 1px #ccc;
}
#txt_inch1, #txt_cm2 {
background: #e7e7e7;
text-align: right;
padding-right: 5px;
width: 58px;
}
.converterCalculation{
overflow: hidden;
border: 1px solid #e7e7e7;
padding: 15px;
}
.converterCalculation .calculation{
color: #000;
height: 33px;
font-weight: bold;
width: 365px;
padding-right: 0;
}
.converterCalculation div.calculation input.last {
height: 26px;
line-height: 26px;
color: #fff;
background: #999;
padding: 0 5px;
margin-left: 5px;
}
</style>
<div class="converterCalculation">
<div class="calculation">Converter:
<input type="text" id="txt_cm1" onkeypress="keyPress(this)" onkeyup="keyUp(this)" onblur="onBlur(this)" />cm
<input type="text" id="txt_inch1" disabled="disabled" value="0.00" />inch
<input type="button" class="last" value="Calculation" onclick="Calculation(1)" />
</div>
<div class="calculation">Converter:
<input type="text" id="txt_inch2" onkeypress="keyPress(this)" onkeyup="keyUp(this)" onblur="onBlur(this)" />inch
<input type="text" id="txt_cm2" disabled="disabled" value="0.00" />cm
<input type="button" class="last" value="Calculation" onclick="Calculation(2)" />
</div>
</div>
<script type="text/javascript"> function keyPress(that){
that.value.match(/^[\+\-]?\d*?\.?\d*?$/)?that.t_value=that.value:that.value=that.t_value;
that.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/)&&(that.o_value=that.value)
}
function keyUp(that){
that.value.match(/^[\+\-]?\d*?\.?\d*?$/)?that.t_value = that.value:that.value = that.t_value;
that.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/) && (that.o_value=that.value)
}
function onBlur(that){
that.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?|\.\d*?)?$/)?(
that.value.match(/^\.\d+$/)&&
(that.value=0+that.value),that.value.match(/^\.$/)&&
(that.value=0),that.o_value=that.value
):that.value = that.o_value
}
function Calculation(type){
var cm1,inch1,inch2,cm2;
type==1 && (
cm1=eval($("#txt_cm1").val()),
cm1==undefined&&(cm1=0),inch1=(cm1/2.54).toFixed(2),
$("#txt_inch1").val(inch1)
);
type==2 && (
inch2=eval($("#txt_inch2").val()),
inch2==undefined&&(inch2=0),cm2=(inch2*2.54).toFixed(2),
$("#txt_cm2").val(cm2)
)
}
</script>
js厘米与英寸尺码转换的更多相关文章
- js中实现字母大小写转换
js中实现字母大小写转换主要用到了四个js函数: 1.toLocaleUpperCase 2.toUpperCase3.toLocaleLowerCase4.toLowerCase 下面就这四个实现 ...
- JS中的进制转换
1 前言 js的进制转换, 分为2进制,8进制,10进制,16进制之间的相互转换, 我们直接利用 对象.toString()即可实现. 仅作为记录. 2 代码 //10进制转为16进制 (10).to ...
- ajax-json,遇到的一个问题,jquery var ,加载顺序。JS对象,json格式转换。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- js数组,字符串,json互相转换函数有哪些
js数组,字符串,json互相转换函数有哪些 一.总结 一句话总结: JSON.stringify(arr) JSON.parse(jsonString) str.split('') array.jo ...
- JS的类型转换,强制转换和隐式转换
JS的类型转换 1.强制转换 通过String(),Number(),Boolean()函数强制转换 var str=123; var str1='123'; console.log(typeof s ...
- libs/tools.js stringToDate dateToString 日期字符串转换函数
libs/tools.js stringToDate dateToString 日期字符串转换函数 import { stringToDate } from '@/libs/tools.js' e ...
- 前端(十七)—— jQuery基础:jQuery的基本使用、JQ功能概括、JS对象与JQ对象转换、Ajax简单应用、轮播图
jQuery的基本使用.JQ功能概括.JS对象与JQ对象转换.Ajax简单应用.轮播图 一.认识jQuery 1.什么是jQuery jQuery是对原生JavaScript二次封装的工具函数集合 j ...
- 使用 js 实现一个中文自动转换成拼音的工具库
使用 js 实现一个中文自动转换成拼音的工具库 中文 => zhong-wen 应用场景 SEO 友好, URL 自动转换 blogs 发布文章,自动化部署,自动生成 url 的 path (时 ...
- c# 刻度:毫米 英寸 像素转换
从目前所掌握的资料来看,c#程序中将毫米转换像素的方法无非两种: 第一种: 1: /// <summary> 2: /// 以毫米为单位的显示宽度 3: /// </summary& ...
随机推荐
- iOS - 消息转发处理
详细运行时基础 NSInvocation介绍 NSHipster-Swizzling Objective-C Method相关方法分析 Type Encodings Objc是OOP,所以有多态. 当 ...
- mysql 创建存储过程报错
在创建存储过程前把结束符定义为 delimiter // 然后再创建就不会报错
- idea maven scala
http://docs.scala-lang.org/tutorials/scala-with-maven.html https://github.com/davidB/scala-archetype ...
- posgresql
ubuntu下 修改postgres数据库用户的密码为123456 sudo -u postgres psql postgres=# ALTER USER postgres WITH PASSWORD ...
- linux 时间同步的2种方法
转载自: http://blog.51yip.com/server/1474.html 由于硬件的原因,机器或多或少的根标准时间对不上,一个月的误差几秒到几分钟不等.对于服务器来说时间不准,会有很多麻 ...
- radio 切换内容
<!DOCTYPE html><html><head> <meta charset=utf-8 /> <title>test</tit ...
- ADB
adb logcat 命令详解 log过滤 http://blog.csdn.net/liao277218962/article/details/50129009 如何使用 adb logcat 查看 ...
- 条件编译#if
1.为什么需要条件编译 客户的需求在不停地发生变化,一会儿需要这个功能,一会儿不需要这个功能.我们可以使用条件编译来方便地裁剪功能. 2.条件编译语句#if 条件编译语句#if的形式是 #if exp ...
- SpringMVC学习记录2
废话 最近在看SpringMVC...里面东西好多...反正东看一点西看一点吧... 分享一下最近的一些心得..是关于DispatcherServlet的 DispatcherServlet与Cont ...
- 请注意,再次记住, centos7,fedora 24中 没有iptables服务, 而使用的firewalld, 也可以安装 iptables-services程序来实现
原来写了一篇文章的, 忘了: http://www.cnblogs.com/bkylee/p/5837481.html 可以用 firewall-cmd 这个命令来管理 防火墙...