假设生成的代码如下:
<input type="file" name="photofile" value=f style="width:;height:22"><BR>
<input type="file" name="photofile" style="width:;height:22"><BR>
<input type="file" name="photofile" style="width:;height:22"><BR>
<input type="file" name="photofile" style="width:;height:22"><BR>
<SCRIPT LANGUAGE="JavaScript">
var arr=document.getElementsByName("photofile");
for(i=0;i<arr.length;i++)
{
alert(arr[i]+i)
}
</SCRIPT>
<input type="file" name="photofile" value=f style="width:;height:22"><BR>
<input type="file" name="photofile" style="width:;height:22"><BR>
<input type="file" name="photofile" style="width:;height:22"><BR>
<input type="file" name="photofile" style="width:;height:22"><BR>
<SCRIPT LANGUAGE="JavaScript">
var arr=document.getElementsByName("photofile");
for(i=0;i<arr.length;i++)
{
alert(arr[i]+i)
}
</SCRIPT>
<input type=text name=txt1 >
<input type=text name=txt1 >
<input type=text name=txt1 >
<input type=text name=txt1 >
<input type=text name=txt1 >
<input type=text name=txt1 >
<input type=text name=txt1 >
<input type=button value="click me" onClick="change()">
</form><SCRIPT LANGUAGE="JavaScript">
<!--
var i = 0;
var myArr = new Array(10); function change()
{
var e = form1.txt1;
alert( e.length );
for( var j = 0; j < e.length; j++ ) {
myArr[j] = e[j].value;
alert( e[j].value );
}
}
//-->
</SCRIPT>