[問題] 按button後將值連續寫入text中

看板Web_Design作者 (.)時間15年前 (2010/08/20 16:02), 編輯推噓0(005)
留言5則, 3人參與, 最新討論串1/1
<input type="button" value="1" onclick="document.getElementById('n1').value='2010-08-1'"> <input type="button" value="2" onclick="document.getElementById('n1').value='2010-08-2'"> <input type="text" id="n1" name="text"> 我希望能在按了button1後再按button2, text會顯示"2010-08-1, 2010-08-2"這樣連續紀錄下去的結果 但是我這樣寫按完button1後再按button2 text只會顯示"2010-08-2"的結果 要怎麼把按過的button後想顯示的值串接起來到text中呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.125.41.241

08/20 16:50, , 1F
document.getElementById('n1').value+='[button1的值]';
08/20 16:50, 1F

08/20 16:51, , 2F
document.getElementById('n1').value+=', [button1值]';
08/20 16:51, 2F

08/20 16:51, , 3F
第二個推文才對!!
08/20 16:51, 3F

08/20 16:57, , 4F
真的有+=
08/20 16:57, 4F

08/20 17:58, , 5F
謝謝1Fy
08/20 17:58, 5F
文章代碼(AID): #1CRZP-m7 (Web_Design)