常用JavaScript的操作

附件增加
<table id="fileUp">
<tr>
<td>
<input type="file" name="file0" size="120"/>
<img src="/yt/secStyle/image/jxtj.gif" align="absmiddle" οnclick="addFile()" />
</td>
</tr>
</table>

var iRow = document.all.row.value;
var num = 0;
增加JS
function addFile()
{
row = fileUp.insertRow(fileUp.rows.length);
num++;
col = row.insertCell(0);
col.innerHTML = "<TD class='item6'><input type=file name=file"+ num + " size=120/><img

src='/yt/secStyle/image/quit.gif' align='absmiddle' οnclick='delrow("+ num +")'></TD>";
}
删除JS
function delrow(curRow)
{
fileUp.rows[curRow].deleteCell(0);
}

检查重复提交

var iscommit=true;
function save(){
if (!iscommit)
{
alert("不能重复提交!");
return false;
}
iscommit=false;
document.forms[0].commit.value = 'true';
document.forms[0].submit();
}

var flag=0;
var isSubmit = false;
//全选
function chkAll(){
var inpts=document.getElementsByTagName("input");
var allc = document.forms[0].chkall;
var chks=new Array();
for(var i=0;i<inpts.length;i++){
var inpt=inpts[i];
if(inpt.type=="checkbox"){
if(flag%2==0)
inpt.checked=true;
else
inpt.checked=false;
}
}
flag++;
if(allc.checked==true){
document.forms[0].sj.value=document.forms[0].row.value;
}else{
document.forms[0].sj.value=0;
}

}


//是否选中了一条订单
function isSelected()
{
var j = 0;
for(var i=1;i<=iRow;i++)
{
if(document.forms[0]["check"+i].checked)
j++;
}
if(j == 0)
{
alert("必须至少选择一个订单!");
return false;
}
}

父窗口js增加输入框信息
function selected(code,name,area,country)
{
var strCode = "window.opener.document.forms[0]." + document.all.percode.value + ".value = '" + code + "';";
var strName = "window.opener.document.forms[0]." + document.all.pername.value + ".value = '" + name + "';";

eval(strCode);
eval(strName);
if(document.all.perarea.value !="")
{
var strArea = "window.opener.document.forms[0]." + document.all.perarea.value + ".value = '" + area + "';";
eval(strArea);
}
if(document.all.percountry.value !="")
{
var strCountry = "window.opener.document.forms[0]." + document.all.percountry.value + ".value = '" + country +

"';";
eval(strCountry);
}
window.close();
}
弹出子窗口
function selCus(colname1,colname2,colname3,colname4)
{
var str = colname1 + ";" + colname2 + ";" + colname3 + ";" + colname4;
SetupModalWin("/yt/custormer.html?method=result&searchTag=true&str="+str,600,500);
}
JS
function SetupModalWin(winURL,winWidth,winHeight)
{
CloseSetupWin();
x = (screen.width-winWidth)/2;
y = (screen.height-winHeight)/2;
popWin = window.open(winURL, "" , "top=" + y + ",left=" + x + ",width=" + winWidth + ",height=" + winHeight+

",resizable=no,scrollbars=yes");
//window.showModalDialog(winURL,window,"dialogWidth:"+winWidth+"px;dialogHeight:"+winHeight+"px;help:no");
}
小写字母转大写
function chackcode(code){
chkHZ();
if(code==""){
document.forms[0].credit_code.focus();
return ;
}
function chkHZ(){
var ele=event.srcElement;
if(trim(ele.value)=='') return true;
if(onlyChar(ele.value)){
ele.value=ele.value.toUpperCase();
}else{
alert("不允许输入汉字!");
ele.value="";
ele.focus();
}
}
// Float数据四舍五入到3位小数;
function to3bits(flt) {
if((""+flt).indexOf(".")==-1){
var le=flt.length;
if(le>3){
flt=flt/1000;
}
}
if(parseFloat(flt) == flt)
{
return Math.round(flt * 1000)/1000;
}
else
return 0;
}
checkbox选中,文本框才能输入内容
<input type='checkbox' name='checkbox1' value='7' οnclick="account.disabled=!this.checked;if (!this.checked)

account.value=''">
<input name='account' value='' size='6' disabled=true>

// 双重列表的互移功能
function moveDualList( srcList, destList, moveAll )
{
// 判断如果什么都没有选中的操作
if ( ( srcList.selectedIndex == -1 ) && ( moveAll == false ) )
{
return;
}

newDestList = new Array( destList.options.length );
var len = 0;
for( len = 0; len < destList.options.length; len++ )
{
if ( destList.options[ len ] != null )
{
newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value,

destList.options[ len ].defaultSelected, destList.options[ len ].selected );
}
}
for( var i = 0; i < srcList.options.length; i++ )
{
if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
{
//如果被选中合并到新列表
newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options

[i].defaultSelected, srcList.options[i].selected );
len++;
}
}
// 挑选出新的目的文件列表,从数组把项目移到目的地
for ( var j = 0; j < newDestList.length; j++ )
{
if ( newDestList[ j ] != null )
{
destList.options[ j ] = newDestList[ j ];
}
}
// 抹去原目的地被选中的项目
for( var i = srcList.options.length - 1; i >= 0; i-- )
{
if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
{
srcList.options[i] = null;
}
}
}
<select name="a" size="8" multiple class="txtarea-duohang" style="width:150px;">
<input οnclick="moveDualList( this.form.a, this.form.b, false )" type="button" value=">>" name=">" class="button-

right-add">
<input οnclick="moveDualList( this.form.b, this.form.a, false )" type="button" value="<<" name="<" class="button-

left-del">
<select name="b" size="8" multiple class="txtarea-duohang" style="width:150px;">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值