摘要:【javascript】選擇數量出現相同輸入框
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5" /> <title>無標題文件</title> </head> <script language="javascript"> function funbt_onclick(obj) { //把所有都關閉 for (i=1; i<=10; i++){ obj_name='fun'+i disp_stats=document.all[obj_name].style.display; document.all[obj_name].style.display="none" } //開啟所需要的部份 for (i=1; i<=obj; i++){ obj_name='fun'+i disp_stats=document.all[obj_name].style.display; document.all[obj_name].style.display="" } } </script> <body> <table width="200" border="0"> <tr> <td width="37">數量</td> <td width="153"> <select name="" onchange="javascript:funbt_onclick(this.value);"> <% for num=0 to 10 %> <option value="<%=num%>"><%=num%></option> <% next %> </select> </td> </tr> <tr> <td colspan="2"> <% for i=1 to 10 %> <div id="fun<%=i%>" style="display:none;"> <table cellpadding="0" cellspacing="0" width="100%" border="0"> <tr> <td><%=i%>:<input name="" type="text" size="5" /></td> </tr> </table> </div> <% next %> </td> </tr> </table> </body> </html>