0
在這裏,我附加了我的java腳本以及html表單,因爲我無法獲得第一個複選框的值並獲取下一個複選框的值。請在此幫助我。文本框中的複選框值
<script type="text/javascript">
var checkboxCount = 0;
var inputTags = document.getElementsByName('pr');
for (var i=0, length = inputTags.length; i <= length ;i++) {
if (inputTags[i].type == 'checkbox') {
checkboxCount++;
}
document.write(checkboxCount);
}
function ATHD() {
var totalValue = '';
for (var i = 1; i < checkboxCount; i++) {
if (document.getElementById(i).checked)
totalValue += inputTags[i].value + ';';
}
document.getElementById("hdnValues").value = totalValue;
document.getElementById("showValues").value = totalValue;
}
<form>
Wraps: <input type="text" id="showValues" name="wrap" /><br />
<input onClick="ATHD()" id="1" type="checkbox" name="pr" value="Password Reset" />*Password Reset<br />
<input onClick="ATHD()" id="2" type="checkbox" name="pr" value="Password Setup" />*Password Setup<br />
<input onClick="ATHD()" id="3" type="checkbox" name="pr" value="Firmware Upgrade (if applicable)" />*Firmware Upgrade (if applicable)<br />
<input onClick="ATHD()" id="4" type="checkbox" name="pr" value="Local Access Setup" />*Local Access Setup<br />
<input onClick="ATHD()" id="5" type="checkbox" name="pr" value="Remote Access Setup" />*Remote Access Setup<br />
<input onClick="ATHD()" id="6" type="checkbox" name="pr" value="Mobile Access Setup" />*Mobile Access Setup<br />
<input onClick="ATHD()" id="7" type="checkbox" name="pr" value="Recording Schedule Setup" />*Recording Schedule Setup<br />
<input onClick="ATHD()" id="8" type="checkbox" name="pr" value="How to playback video" />*How to playback video<br />
<input onClick="ATHD()" id="9" type="checkbox" name="pr" value="How to convert video" />*How to convert video<br />
<br />
<input type="hidden" id="hdnValues" />
所以要根據你我應該怎麼做嗎?我沒有得到任何想法...請幫助我.. – Yash
你能否請詳細說明你的問題即時通訊沒有得到你想要實現什麼 –
實際上我想多個選中的複選框值在文本框中我定義變量checkboxCount? – Yash