海綿寶寶撒
2019-04-19 10:15:23
我想知道當(dāng)選中單選按鈕時,它取消選中其他對象單選按鈕。我有一個對象,對于每個對象選項,都會創(chuàng)建單選按鈕。例如,對于id = SG,將創(chuàng)建兩個單選按鈕,如果未選中,則將bank設(shè)置為默認(rèn)選中,否則將相應(yīng)的所選無線電值設(shè)置為已選中。我被困在文字中。對于每個obj無線電選項都會生成,默認(rèn)情況下會選中第一個選項,但如果我選中creditobj的選項SG,則取消選中默認(rèn)選項 THconst obj= [{
id: "SG",
options: ["bank", "credit"]
},
{
id: "TH",
options: ["bank","debit"]
}];render(){
${obj.map((e)=>{return html`
<form>
${obj.options.map((option_value)=>{
return html`
<input class="form-check-input" name="sending-${country.id}" type="radio" id="provider-send-${option_value}"
value=${option_value} ?checked=${option === 'bank'} >
<label class="form-check-label">
${option_value}
</label><br>
`})}
</form>
})`;}對于每個obj,如果檢查了obj的特定無線電,則應(yīng)檢查默認(rèn)無線電選項
2 回答

陪伴而非守候
TA貢獻(xiàn)1757條經(jīng)驗 獲得超8個贊
嘗試將復(fù)選框組的名稱更改為類似的名稱 sendingCountries[]
<label><input type="checkbox" name="sendingCountries[]" value="Malaysia" /> Malaysia</label>
<label><input type="checkbox" name="sendingCountries[]" value="Thailand" /> Thailand</label>
<label><input type="checkbox" name="sendingCountries[]" value="Singapore" /> Singapore</label>
<label><input type="checkbox" name="sendingCountries[]" value="USA" /> USA</label>
<label><input type="checkbox" name="sendingCountries[]" value="Ireland" /> Ireland</label>
添加回答
舉報
0/150
提交
取消