[問題] javascript新增選單的問題

看板Ajax作者 (uishi)時間15年前 (2009/06/07 17:47), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
我這個例子只能新增一個選單,然後就不能在新增了 請問一下,我要怎麼每按ㄧ次就新增一個選單? 而select name 每次都不ㄧ樣? 我是初學javascript 請高手幫忙 下面是我的原始碼: <%@ page contentType="text/html; charset=big5" language="java" import="java.sql.*" errorPage="" %> <%@page import ="java.io.IOException"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5" /> <title>無標題文件</title> </head> <script language="javascript"> function add() { var str = ''; str += '<select name="s1">'; str += '<option value="PC">桌上型電腦</option>'; str += '<option value="NB">筆記型電腦</option>'; str += '</select>'; //取出 id 為 newAdd 的物件,並塞入 str 的內容 int i; for(i=0;i>=1;i++) } </script> <body> <form id="form1" name="form1" method="post" action=""> <label></label> <label> <input type="button" value="+" onclick="add()"> <span id="newAdd"></span> <br /> </label> <input name="Submit2" value="新增內容" onClick="addRowInnerHTML('test')" type="button"></td> </form> </body> </html> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.68.92.166
文章代碼(AID): #1AAuoW8a (Ajax)
文章代碼(AID): #1AAuoW8a (Ajax)