Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I know what I select in every group #34

Open
Zen05 opened this issue Apr 1, 2019 · 0 comments
Open

how can I know what I select in every group #34

Zen05 opened this issue Apr 1, 2019 · 0 comments

Comments

@Zen05
Copy link

Zen05 commented Apr 1, 2019

I want to know what i select in every group ,but i can't do it. everybody hlpe me, please
this is my data

this is this.state.data: Array [
 Object {
   "A": "采取国务院发布的放假方案调休,共四天假期",
   "B": "在上述方案下再将前一周的周六调至五一假期中,共五天假期",
   "C": null,
   "D": null,
   "qid": 1,
   "tid": 1,
   "title": "五一即将来临,我们将对五一的休假计划做意见收集",
 },
 Object {
   "A": "不补假",
   "B": "补周一的假",
   "C": "补周二的假",
   "D": "补周3的假",
   "qid": 1,
   "tid": 2,
   "title": "五一补假方案",
 },
 Object {
   "A": "参加",
   "B": "不参加",
   "C": null,
   "D": null,
   "qid": 1,
   "tid": 3,
   "title": "五一是否参加学校组织的活动",
 },
 Object {
   "A": "不去玩,认真学习",
   "B": "在家自己玩",
   "C": "找朋友玩",
   "D": "出去玩",
   "qid": 1,
   "tid": 4,
   "title": "五一不参加活动你去哪里玩",
 },
]

this is my demo

    onSelect=(index, value)=>{
        console.log(`you select ${index} and result is ${value}`)
        this.setState((prevState)=>{
            var arr = prevState.select;
            arr[index]=value; 
            return{
                select: arr
            }
        })
      }
     this.state.data.map((values,index)=>{
                            var {A,B,C,D,E,F,G,H,I} = values;
                            return (
                            <View
                                key={values.title}
                            >
                                <View style={{marginTop:15}}>
                                    <Text>{`${index+1}.${values.title}`}</Text>
                                </View>
                                <RadioGroup
                                    key={index}
                                    onSelect={(index, value) => this.onSelect(index, value)}>
                                   
                                    <RadioButton value={`A`}>
                                        <Text>{`A.${A}`}</Text>
                                    </RadioButton>

                                    <RadioButton value={`B`}>
                                        <Text>{`B.${B}`}</Text>
                                    </RadioButton>

                                    <RadioButton value={`C`} style={{display: C ? "flex" : "none"}}>
                                        <Text>{`C. ${C}`}</Text>
                                    </RadioButton>

                                    <RadioButton value={`D`} style={{display: D ? "flex" : "none"}}>
                                        <Text>{`D. ${D}`}</Text>
                                    </RadioButton>

                            </View>)
                        })
                    }  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant