在javascript中显示选定值单选按钮组

时间:2019-04-08 01:53:48

标签: javascript jquery html arrays object

我想知道如何使用javascript在单选按钮组中显示选定值的对象, 我有两个具有默认选中选项的单选按钮组,如何使用javascript显示选中的单选按钮的对象。

我尝试过但被卡住,如何根据单选按钮的选择显示对象,

npm install <my_username>/puppeteer-extra --save
${obj.map.funtion((e)=>{
<div class="form-check" onClick=${(e)=>this.handleSelect(e,obj)}>
    <input class="form-check-input" name="sending" type="radio" value="bank transfer" Checked>
Bank Transfer
<br>
    <input class="form-check-input" name="sending" type="radio" value="credit">                                                                                       Credit Card
</div>});

handleSelect(e){
      const temp = obj.map(e => Object.entries(e).map(([k, val]) => val)).flat(2)
    var selectvalue = temp.filter(x=>x.in == selectvalue && x.id == id);  
    var defaultvalue = temp.filter(e=>
      e.id !== id && e.in==e.target.value
    )

}
var obj = [{
    "btob": [{
      "id": "trans",
      "in": "bank",
      "out": "bank",
      "value": 10
    },{
      "id": "fund",
      "in": "bank",
      "out": "bank",
      "value": 10
    }],
    "ctob": [{
      "id": "trans",
      "in": "credit",
      "out": "bank",
      "value": 20
    },{
      "id": "fund",
      "in": "credit",
      "out": "bank",
      "value": 10
    }]
}]

0 个答案:

没有答案