日期:2014-05-16  浏览次数:20408 次

常用JS方法

function changeDisplayMode(nodename)
{
????? var inputs =document.getElementsByTagName(nodename)
????? var length=inputs.length;
????? for(var i=0; i<length ; i++)
???? {
?????????? if(inputs[i].id!="btn_edit"&&inputs[i].id!="btn_save")
????????? {
??????????????? inputs[i].disabled=true;
???????? ?}

???? }
}
function changeModifyMode(nodename)
{
???? var inputs =document.getElementsByTagName(nodename)
???? var length=inputs.length;
???? for(var j=0;j<length;j++)
??? {
????????? if(inputs[j].id!=null)
?????? ? {
????????????? ??inputs[j].disabled=false;
????????????? ? inputs[j].style.color="#000000";
???????? }
??? }?
?????document.getElementById("btn_save").style.display="block";
???? document.getElementById("btn_edit").style.display="none";
}
???? window.onload=function(){
?????????? changeDisplayMode('input');
?? };

<input type="button" value="MODIFY" id="btn_edit" onclick="changeModifyMode('input')" />
<input type="button" value="SAVE" id="btn_save" style="display:none" onclick="modifyEnterprise()"/>

?

function testfunc(){
??var funcFlag="";
??var name="";
??var input = document.getElementsByTagName("input");
??alert(input.length);
??for(var i=0;i<input.length;i++){
???if(input[i].type=="checkbox"){
????name = name+input[i].value+",";
????funcFlag = funcFlag+((input[i] != null && input[i].checked)? "1" : "0");
???}?
??}
??alert(funcFlag);
??alert(name);
?}

?