我试图通过单选按钮单击在div中获取该值(该值是从数组中获取的)。如何获取该值?
fn(){
value
}
{id1 && id1.map(list =>
<div style={{padding:'6px 6px'}}>
{"ClaimID:"+ list.ID+' '+'-'+"PatientID:"+list.RCID+' '+'-'+' '+"Amount:" +new Intl.NumberFormat('en-USD', {currency: 'USD' ,style: 'currency'}).format(Number(list.Amount))}
<input type='radio' name={'PatientID: ' + list.RCID} vlaue={'PatientID: ' + list.RCID} style={{width: '50px'}} /> </div>)}
答案 0 :(得分:2)
虽然您的问题不清楚,但我认为您可以使用以下代码:
state = {
selectedRadioValue: null
}
changeRadioButton = (e) => {
if(e.target.value == true){
this.setState({
selectedRadioValue : e.target.value
})
}
}
render() {
return(
<div>
<input type='radio' onChange= {(e) => {this.changeRadioButton(e)}}/>
<input type='radio' onChange= {(e) => {this.changeRadioButton(e)}}/>
</div>
)
}