获取checkbox的文本值
var r=document.getElementsByName("r");
for(var i=0;i<r.length;i++){
if(r[i].checked){
alert(r[i].value+","+r[i].nextSibling.nodeValue);
}
}
获取select的文本值
var roomTypeNameValue = $("#roomTypeCode_id option:selected").text();
ajax的get请求中文参数处理
var name = encodeURIComponent("李四");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>用正则表达式控制价格输入</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<script type="text/javascript">
var record={
num:""
}
var checkDecimal=function(n){
var decimalReg=/^\d{0,8}\.{0,1}(\d{1,2})?$/;//var decimalReg=/^[-\+]?\d{0,8}\.{0,1}(\d{1,2})?$/;
if(n.value!=""&&decimalReg.test(n.value)){
record.num=n.value;
}else{
if(n.value!=""){
n.value=record.num;
}
}
}
</script>
</head>
<body>
<h3>实用技巧:用正则表达式控制价格输入</h3>
销售价<input maxlength="10" size="18" type="text" name="price" value="" οnkeyup='checkDecimal(this)'/>
</body>
</html>
图片上传时,file一定要有name
var r=document.getElementsByName("r");
for(var i=0;i<r.length;i++){
if(r[i].checked){
alert(r[i].value+","+r[i].nextSibling.nodeValue);
}
}
获取select的文本值
var roomTypeNameValue = $("#roomTypeCode_id option:selected").text();
ajax的get请求中文参数处理
var name = encodeURIComponent("李四");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>用正则表达式控制价格输入</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<script type="text/javascript">
var record={
num:""
}
var checkDecimal=function(n){
var decimalReg=/^\d{0,8}\.{0,1}(\d{1,2})?$/;//var decimalReg=/^[-\+]?\d{0,8}\.{0,1}(\d{1,2})?$/;
if(n.value!=""&&decimalReg.test(n.value)){
record.num=n.value;
}else{
if(n.value!=""){
n.value=record.num;
}
}
}
</script>
</head>
<body>
<h3>实用技巧:用正则表达式控制价格输入</h3>
销售价<input maxlength="10" size="18" type="text" name="price" value="" οnkeyup='checkDecimal(this)'/>
</body>
</html>
图片上传时,file一定要有name