幾個javascript例子.
=================================================
像下面的這樣的物件在對期進行付值時應該用innerHtml
==================================================
<textarea name="textfield"></textarea>
<span></span>
<div></div>
也就是沒有value屬性的標簽
if(frm.chk.checked){
frm.textarea.innerHtml+=(frm.textarea.innerHtml=''?'':';')+frm.chk.value
}
===================幾個例子-====================
<script language="JavaScript">
<!--
function checkadd()
{
var seled_wn=window.opener.document.<%=request("frm1")%>.value;
var seled_misid=window.opener.document.<%=request("frm2")%>.value;
for(var i=0;i<frm.elements.length;i++)
{
if(frm.elements[i].type=="checkbox")
{
if(frm.elements[i].checked)
{
if (seled_wn=='')
{
seled_wn=frm.elements[i].value;
}
else
{
seled_wn=seled_wn+";"+frm.elements[i].value;
}
if(seled_misid=='')
{
seled_misid=frm.elements[i].stylesid;
}
else
{
seled_misid=seled_misid+","+frm.elements[i].stylesid;
}
}
}
}
frm.selected_wn.value="";
frm.selected_mis_id.value="";
window.opener.document.<%=request("frm1")%>.value=window.opener.document.<%=request("frm1")%>.value+seled_wn;
window.opener.document.<%=request("frm2")%>.value=window.opener.document.<%=request("frm2")%>.value+seled_misid;
}
function returnVal()
{
var workingno="";
var allStylesid=",";
for(i=1;i<<%=j-1%>;i++)
{
if(document.getElementById("chk_"+ i).checked)
{
if(workingno=="")
{
workingno=document.getElementById("chk_"+ i).value;
}
else
{
workingno=workingno +";"+ document.getElementById("chk_"+ i).value;
}
currMisid=document.getElementById("chk_"+ i).stylesid ;
vtemp = ","+ currMisid +","
if(allStylesid.indexOf(vtemp) == -1)
{
allStylesid = allStylesid + document.getElementById("chk_"+ i).stylesid +"," ;
}
}
}
allStylesid = allStylesid.substring(1,allStylesid.length-1);
if (allStylesid==","){allStylesid="";}
window.opener.document.<%=request("frm1")%>.value = workingno ;
window.opener.document.<%=request("frm2")%>.value = allStylesid ;
self.close();
}
function selall(flag)
{
for(var i=0;i<frm.elements.length;i++)
{
if(frm.elements[i].type=="checkbox")
{
frm.elements[i].checked=flag;
}
}
}
function notsel()
{
for(var i=0;i<frm.elements.length;i++)
{
if(frm.elements[i].type=="checkbox")
{
frm.elements[i].checked=!frm.elements[i].checked;
}
}
}
//-->
</script>
像下面的這樣的物件在對期進行付值時應該用innerHtml
==================================================
<textarea name="textfield"></textarea>
<span></span>
<div></div>
也就是沒有value屬性的標簽
if(frm.chk.checked){
frm.textarea.innerHtml+=(frm.textarea.innerHtml=''?'':';')+frm.chk.value
}
===================幾個例子-====================
<script language="JavaScript">
<!--
function checkadd()
{
var seled_wn=window.opener.document.<%=request("frm1")%>.value;
var seled_misid=window.opener.document.<%=request("frm2")%>.value;
for(var i=0;i<frm.elements.length;i++)
{
if(frm.elements[i].type=="checkbox")
{
if(frm.elements[i].checked)
{
if (seled_wn=='')
{
seled_wn=frm.elements[i].value;
}
else
{
seled_wn=seled_wn+";"+frm.elements[i].value;
}
if(seled_misid=='')
{
seled_misid=frm.elements[i].stylesid;
}
else
{
seled_misid=seled_misid+","+frm.elements[i].stylesid;
}
}
}
}
frm.selected_wn.value="";
frm.selected_mis_id.value="";
window.opener.document.<%=request("frm1")%>.value=window.opener.document.<%=request("frm1")%>.value+seled_wn;
window.opener.document.<%=request("frm2")%>.value=window.opener.document.<%=request("frm2")%>.value+seled_misid;
}
function returnVal()
{
var workingno="";
var allStylesid=",";
for(i=1;i<<%=j-1%>;i++)
{
if(document.getElementById("chk_"+ i).checked)
{
if(workingno=="")
{
workingno=document.getElementById("chk_"+ i).value;
}
else
{
workingno=workingno +";"+ document.getElementById("chk_"+ i).value;
}
currMisid=document.getElementById("chk_"+ i).stylesid ;
vtemp = ","+ currMisid +","
if(allStylesid.indexOf(vtemp) == -1)
{
allStylesid = allStylesid + document.getElementById("chk_"+ i).stylesid +"," ;
}
}
}
allStylesid = allStylesid.substring(1,allStylesid.length-1);
if (allStylesid==","){allStylesid="";}
window.opener.document.<%=request("frm1")%>.value = workingno ;
window.opener.document.<%=request("frm2")%>.value = allStylesid ;
self.close();
}
function selall(flag)
{
for(var i=0;i<frm.elements.length;i++)
{
if(frm.elements[i].type=="checkbox")
{
frm.elements[i].checked=flag;
}
}
}
function notsel()
{
for(var i=0;i<frm.elements.length;i++)
{
if(frm.elements[i].type=="checkbox")
{
frm.elements[i].checked=!frm.elements[i].checked;
}
}
}
//-->
</script>
申明
非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!
博文欢迎转载,但请给出原文连接。