我想顯示多個選定選項的多個結果,在這裏我顯示我的PHP和JavaScript代碼。如何在JavaScript中顯示多個結果?
function save() {
if (!validateSave())
return;
var e;
var result;
e = document.getElementsByName("q1[]");
for (var j = 0; j <= e.length - 1; j++) {
if (e[j].checked) {
result = "1:" + e[j].value;
//break;
}
}
HTML代碼
<div class="qright">
<!-- multioption handler --------------------------------------------------->
<input type="hidden" name="multioption" value="true" />
<!-- end ------------------------------------------------------------------->
<label for="q1"><input type="checkbox" name="q1[]" value="1" class="styled" />Reducing cost</label>
<label for="q1"><input type="checkbox" name="q1[]" value="2" class="styled" />Upgrading your hardware and software infrastructure</label>
<label for="q1"><input type="checkbox" name="q1[]" value="3" class="styled" />Aligning the IT goals with the overall business strategy</label>
<label for="q1"><input type="checkbox" name="q1[]" value="4" class="styled" />Enabling agile working</label>
<label for="q1"><input type="checkbox" name="q1[]" value="5" class="styled" />Streamlining supplier management</label>
<label for="q1"><input type="checkbox" name="q1[]" value="6" class="styled" />Improving network availability/access</label>
<label for="q1"><input type="checkbox" name="q1[]" value="7"class="styled" />Improving the utilisation of your network</label>
</div>
,如果我選擇多個選項,然後它也只顯示一個值,我應該在JavaScript函數改變?
我要救這個結果餅乾 –
尼斯編輯,我知道這不是建設性的,但我的意見是沒有現在感覺:(。 –
@MarkWalters但是我們知道你是關於:D +1 – VisioN