Reactjs 表单语义用户界面反应 ({ 姓名:cu.Id,, 关键字:cu.Id, 值:cu.Name, 文本:cu.Name }))} />

Reactjs 表单语义用户界面反应 ({ 姓名:cu.Id,, 关键字:cu.Id, 值:cu.Name, 文本:cu.Name }))} />,reactjs,forms,validation,element,semantic-ui-react,Reactjs,Forms,Validation,Element,Semantic Ui React,我需要使用此select的值,通过将值发送到函数来存储在数据库中。但它没有传递任何价值?有人可以帮忙吗?const options=[ <Form.Select label="Customer Id" name="customer.id" compact options={this.state.customer.map(cu => ({

我需要使用此select的值,通过将值发送到函数来存储在数据库中。但它没有传递任何价值?有人可以帮忙吗?

const options=[
<Form.Select
        label="Customer Id"
        name="customer.id"                                       
        compact
        options={this.state.customer.map(cu => ({                                
           name: cu.Id,
           key: cu.Id,
           value: cu.Name, 
           text: cu.Name
        }))} 
/>
{键:“m”,文本:“Male”,值:“Male”}, {键:“f”,文本:“女性”,值:“女性”}, {键:“o”,文本:“其他”,值:“其他”} ]; _选择性别=(事件,val)=>{ event.preventDefault(); console.log(“>>”,val.value); };
像这样试试。
你会从中得到价值

如果你能正确地格式化你的代码,并且你有有效的语法,这对人们阅读会更有帮助。另外,您需要制定一个明确的问题。是的,我在console.log中得到了值。但是,当我试图在salesproductid中设置state值时,它不会被插入。我的代码是:_-selectproduct=(event,val)=>{event.preventDefault();console.log(“>>”,val.value)this.setState({salesproductid:event.target.val});}u-selectGender=(event,val)=>{event.preventDefault();this.setState({salesproductid:val.value});您必须获取val.value,而不是event.target.value。但我仍然无法获取salesproductid中的值。如何在相同的_selectgender函数中检查salesproductid中的值?该值正在该函数中,但无法分配给salesproductid。this.setState({salesproductid:val.value},()=>{console.log('updated state in callback fun',this.state)})我在控制台中看到了该值。我有三个下拉列表保存在一个表单中。提交表格时,该值消失。但是非常感谢你的帮助。我被这个问题困扰了5,6天,但仍然无法在数据库中提交。
const options = [
  { key: "m", text: "Male", value: "male" },
  { key: "f", text: "Female", value: "female" },
  { key: "o", text: "Other", value: "other" }
];

_selectGender = (event,val) => {
  event.preventDefault();
  console.log(">>", val.value);
};

  <Form.Select
    fluid
    label="Gender"
    options={options}
    placeholder="Gender"
    onChange={this._selectGender}
  />