私は非常に単純なHTMLページにさまざまなチェックボックスを使用しています。そのうち3つを選択して下の製品名を表示したいと思います。HTML 3つの異なるチェックボックスを選択して表示
3つの香水
- オードールを選択してください
- 熱帯イッセイを:私はチェックボックスが1、3、4Nº選択した場合
は私が必要なもの、例えば、私は確認する必要があります
- Eau d'Issey2
1つのチェックボックスをクリックするたびに、3つの同じ結果が得られます。誰もそれで私を助けることができますか? 私のコードは以下です
ありがとうございました!
<html>
<head>
<script language="javascript" type="text/javascript">
function exefunction(me) {
var check = document.getElementById(me.id).checked;
var checked_value;
var str1 = "product";
var n = 1;
for (i = 0; i <= 2; i++) {
if (check) {
checked_value = document.getElementById(me.id).name
document.getElementById("product" + n).innerHTML = checked_value;
n++;
}
}
}
</script>
</head>
<body>
<p>1.
<input type="checkbox" id="1" name="Eau d'Issey" title="Select All" onclick="exefunction(this);">
<p>2.
<input type="checkbox" id="2" name="Fahrenheit" title="Select All" onclick="exefunction(this);">
<p>3.
<input type="checkbox" id="3" name="Tropical" title="Select All" onclick="exefunction(this);">
<p>4.
<input type="checkbox" id="4" name="Eau d'Issey2" title="Select All" onclick="exefunction(this);">
<p>5.
<input type="checkbox" id="5" name="Fahrenheit2" title="Select All" onclick="exefunction(this);">
<p>6.
<input type="checkbox" id="6" name="Tropical2" title="Select All" onclick="exefunction(this);">
<p>Choose 3 perfumes.</p>
<h3>1: </h3>
<p id="product1"></p>
<h3>2: </h3>
<p id="product2"></p>
<h3>3: </h3>
<p id="product3"></p>
</body>
</html>
スニペットエディタで整頓ボタンを使用してください。 – Roope