作者LPH66 (ha(ruhi|yate)ism)
看板Web_Design
標題Re: [請益] 將radio button值傳至text欄位
時間Sun May 6 15:04:02 2007
※ 引述《one0one (one0one)》之銘言:
: <input type="text" name="text1" value=""/>
: 我利用Radio button,請問要如何將所選定的m_id,即時傳入本頁面的text欄位中?
: 煩請高手幫忙解惑,感謝!!
你最後出現的HTML是類似下面的這樣嘛?
<input type="radio" name="m_id[]" value="value1"> value1
<input type="radio" name="m_id[]" value="value2"> value2
...
那麼 在每個input當中加
onClick="document.getElementById('
textfield').value=this.value"
然後把那個text欄位加一個 id="
textfield"
綠字可自行更換
--
其實是有個getElementsByName啦
但是我記得它傳回來的好像是個陣列 (因為name可以重覆)
而getElementById回傳的就是那個元件 (因為id不能重覆)
所以還是加個id好用些
--
'Oh, Harry, dont't you
see?' Hermione breathed. 'If she could have done
one thing to make
absolutely sure that every single person in this school
will read your interview, it was
banning it!'
---'Harry Potter and the order of the phoenix', P513
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 192.192.197.115
1F:推 appleboy46:document.getElementByName('m_id[]')[數字] 陣列 05/06 21:30