<div class="codetitle"> <span><a style="CURSOR: pointer" data="70887" class="copybut" id="copybut70887" onclick="doCopy('code70887')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code70887"><html> <br><head> <br><meta http -equiv="Content-Type" content="text/html; charset=gb2312"> <br><title>Control of elements with the same name</title> <br><script language="javascript"> <br> function setFlag(aObj) <br> { <br> if (!aObj) <br> return false; <br> if(aObj.form.box .length>1) //More than one <br> 🎜> for (i=0;i<aObj.form.box.length;i) <BR> if (aObj.form.box[i]==aObj) <BR> if (aObj.form.box [i] .checked) <BR> aObj.form.txt[i].value="ok"; <BR> else <BR> aObj.form.txt[i].value=""; 🎜> <BR> /script> <br></ head> <br><br><body> <br><form name="form1" method="post" action=""> <br>1<input name="box" type="checkbox" id="box" value="" onClick="javascript:setFlag(this);"/><input name="txt" type="text" id="txt" /><br> <br>2<input name="box" type="checkbox" id="box" value="" onClick="javascript:setFlag(this);" /><input name="txt" type="text" id="txt" /><br> <br>3<input name="box" type="checkbox" id="box" value="" onClick="javascript:setFlag(this);" /> ;<input name="txt" type="text" id="txt" /> <br></form> <br></body> <br></html> <br><br> </div>