普元Js将页面输入框改为查看显示
function viewAction(){
var inputs = document.getElementsByTagName("input");
var selects = document.getElementsByTagName("select");
var textareas = document.getElementsByTagName("textarea");
var spans = document.getElementsByTagName("span");
for(var i = 0; i < inputs.length; i ++) {
if(inputs[i].type != 'button' && inputs[i].type != 'hidden'&&inputs[i].type != 'checkbox' &&inputs[i].type != 'radio') {
if(inputs[i].parentElement.tagName=="TD"){
inputs[i].parentElement.innerHTML="<span style='display:none'>"+inputs[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+inputs[i].value+"</font>";
}else if(inputs[i].parentElement.tagName=="DIV"){
inputs[i].parentElement.innerHTML="<span style='display:none'>"+inputs[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+inputs[i].value+"</font>";
}else{
inputs[i].parentElement.parentElement.innerHTML="<span style='display:none'>"+inputs[i].parentElement.parentElement.innerHTML+"</span><font style='color:#003333'>"+inputs[i].value+"</font>";
}
}else if(inputs[i].type == 'checkbox' || inputs[i].type == 'radio'){
inputs[i].disabled = true;
}
}
for(var i = 0; i < selects.length; i ++) {
var index = selects[i].selectedIndex;
if(selects[i].parentElement.tagName=="TD"){
selects[i].parentElement.innerHTML="<span style='display:none'>"+selects[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+selects[i].options[index].text+"</font>";
}else if(selects[i].parentElement.tagName=="DIV"){
if(selects[i].datacellEditor == "true"){
continue;
}
selects[i].parentElement.innerHTML="<span style='display:none'>"+selects[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+selects[i].options[index].text+"</font>";
}else{
selects[i].parentElement.parentElement.innerHTML="<span style='display:none'>"+selects[i].parentElement.parentElement.innerHTML+"</span><font style='color:#003333'>"+selects[i].options[index].text+"</font>";
}
}
for(var i = 0; i < textareas.length; i ++) {
if(textareas[i].parentElement.tagName=="TD"){
textareas[i].parentElement.innerHTML="<span style='display:none'>"+textareas[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+textareas[i].value+"</font>";
}else if(textareas[i].parentElement.tagName=="DIV"){
textareas[i].parentElement.innerHTML="<span style='display:none'>"+textareas[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+textareas[i].value+"</font>";
}else{
textareas[i].parentElement.parentElement.innerHTML="<span style='display:none'>"+textareas[i].parentElement.parentElement.innerHTML+"</span><font style='color:#003333'>"+textareas[i].value+"</font>";
}
}
for(var i =0;i<spans.length;i++){
if((spans[i].style.color=='red')||((spans[i].style.color=='blue'))){
spans[i].innerHTML="<span style='display:none'>"+"</span>";
}
}
}
function viewActionExceptTextareas(){
var inputs = document.getElementsByTagName("input");
var selects = document.getElementsByTagName("select");
for(var i = 0; i < inputs.length; i ++) {
if(inputs[i].type != 'button' && inputs[i].type != 'hidden'&&inputs[i].type != 'checkbox' &&inputs[i].type != 'radio'&&inputs[i].type != 'textareas') {
if(inputs[i].parentElement.tagName=="TD"){
inputs[i].parentElement.innerHTML="<span style='display:none'>"+inputs[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+inputs[i].value+"</font>";
}else if(inputs[i].parentElement.tagName=="DIV"){
inputs[i].parentElement.innerHTML="<span style='display:none'>"+inputs[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+inputs[i].value+"</font>";
}else{
inputs[i].parentElement.parentElement.innerHTML="<span style='display:none'>"+inputs[i].parentElement.parentElement.innerHTML+"</span><font style='color:#003333'>"+inputs[i].value+"</font>";
}
}
} for(var i = 0; i < selects.length; i ++) {
var index = selects[i].selectedIndex;
if(selects[i].parentElement.tagName=="TD"){
selects[i].parentElement.innerHTML="<span style='display:none'>"+selects[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+selects[i].options[index].text+"</font>";
}else if(selects[i].parentElement.tagName=="DIV"){
if(selects[i].datacellEditor == "true"){
continue;
}
selects[i].parentElement.innerHTML="<span style='display:none'>"+selects[i].parentElement.innerHTML+"</span><font style='color:#003333'>"+selects[i].options[index].text+"</font>";
}else{
selects[i].parentElement.parentElement.innerHTML="<span style='display:none'>"+selects[i].parentElement.parentElement.innerHTML+"</span><font style='color:#003333'>"+selects[i].options[index].text+"</font>";
}
}
}