`

常用js总结

js 
阅读更多

 

select多选

jQuery(function(){

 jQuery("select[name='DATA_5']").val(jQuery("input[name='DATA_6']").val().split(","));

 jQuery("select[name='DATA_5']").change(function(){
  jQuery("input[name='DATA_6']").val(jQuery(this).val());
 });

});

 

 

WdatePicker

onFocus="WdatePicker({onpicking:function(dp){sjset(dp.cal.getNewDateStr());}})"

 

监视value变化

$("input[lx='sz']").bind("propertychange", function() {

if(isNaN($(this).val())){$(this).val("")}
});

 

 

必填

function bitian(){

var bt = jQuery("input[bitian='bitian']");
bt.after(" <span style='color:red'>*</span>");

jQuery("#Submit").attr("onclick", "");
jQuery("#Submit").click(function() {

    var ll = 0;
    bt.each(function(i) {

        if (jQuery(this).val() == '') {
            ll++;
        }
    });

    if (ll > 0) {

        alert("请填写完整!");

    } else {
        CheckForm();

    }

}

 

获取get变量

function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}

 

iframe高度自适应

function dyniframesize(down) {
    var pTar = null;
    if (document.getElementById) {
        pTar = document.getElementById(down);
    } else {
        eval('pTar = ' + down + ';');
    }
    if (pTar && !window.opera) {
        pTar.style.display = "block"
        if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
            pTar.height = pTar.contentDocument.body.offsetHeight + 20;
        } else if (pTar.Document && pTar.Document.body.scrollHeight) {
            pTar.height = pTar.Document.body.scrollHeight;
        }
    }
}

 

 

 CSS截取字符串省略号效果
li a {display: block;width: 120px;overflow: hidden;/*注意不要写在最后了*/white-space: nowrap;-o-text-overflow: ellipsis;text-overflow: ellipsis;}

table布局

table{margin-left:auto; margin-right:auto; line-height:22px;width:190mm; }
.table1{border-collapse:collapse}
.table4{border-collapse:collapse; margin-top:-1px; margin-bottom:-1px;}
.table4 td,.table1 td{ border:1px solid #000; padding:5px; font-size:14px;}
.table2{ border:0; width:100% }
.table2 td{ border:0; }
 

 

表格宽度固定不变形

table {table-layout:fixed;word-break:break-all;word-wrap:break-word;}

 

 

getJSON遍历
function hq(){
id=jQuery("input[name='DATA_61']").val();
jQuery.getJSON( "/module/chuanbo.php",{sbh:id,rand:new Date().getTime()+Math.random()}, function(j){
for(k in j){
   jQuery("input[name='"+k+"']").val(j[k]);
}
});
}

 

 虚拟主机配置
<VirtualHost *:80>
ServerName sz120oa.my0557.com
DocumentRoot e:/oa
<Directory e:/oa>
AllowOverride All
Options All
</Directory>
php_value include_path e:/oa
</VirtualHost>

 

 

  NameVirtualHost *

 

<VirtualHost *>

 

DocumentRoot "E:\MYOA\webroot"   

 

 

ServerName *

 

ServerAlias *

 

</VirtualHost>

 

<VirtualHost *>

 

DocumentRoot "E:\MYOA\module"

 

ServerName www.rjkf.org

 

ServerAlias *

 

</VirtualHost>

 

 

 function hq(){
id=jQuery("input[name='DATA_61']").val();


jQuery.getJSON( "/module/chuanbo.php",{sbh:id,rand:new Date().getTime()+Math.random()}, function(j){

for(k in j){
//alert(jQuery("*[name='"+k+"']").attr("tagName"));


   jQuery("*[name='"+k+"']").val(j[k]);

}


});

}

 

列合计

function heji1(eq){ var sum=0; $("#gzb .Tabledata").each(function(){ var z=$(this).find("td").eq(eq).html()*1; sum+=z; }); $("#gzb .TableControl").find("td").eq(eq).html(sum); } heji1(8);

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics