文档对象在反应形式中未定义

时间:2018-06-15 20:31:21

标签: javascript forms reactjs

我有一个纯粹的javascript表单,可以使用此函数自动提交:

<script language="Javascript" > 
function OnLoadEvent(){ 
document.threedfrom.submit(); 
}
</script>
</head> 
<body OnLoad="OnLoadEvent();" > 
<form name="threedfrom" action="https://a12232.com" method="POST"> 

因此,表单在加载页面时提交。我试图在反应类中应用相同的功能。我的组件的一部分在这里:

handleSubmit() {
    ReactDOM.findDOMNode(this.refs.threedfrom).submit();
  }
  render() {
    }
    return (
        <form onSubmit={this.handleSubmit} ref="threedfrom" name="threedfrom" action={this.props.acsUrl} method="POST">
          <textarea style={{ display: 'none' }} name="PaReq"

但它似乎不起作用,因为我的表单没有提交加载页面。有任何想法吗?我也添加了这个

componentDidMount() {
    ReactDOM.findDOMNode(this.refs.threedfrom).submit();
  }

但没有结果

1 个答案:

答案 0 :(得分:0)

尝试将[Serializable] [Template(TemplateUsage.EnumSelectOne, "Selecciona un estadio: {||}", ChoiceStyle = ChoiceStyleOptions.PerLine)] public class StadiumInfoForm { [Prompt("Selecciona un estadio: ", ChoiceFormat = "{1}")] public StadiumOptions? estadio; public static IForm<StadiumInfoForm> BuildForm() { var form = new FormBuilder<StadiumInfoForm>() .Message($"¿De qué estadio te gustaría saber?") .AddRemainingFields(); PromptAttribute title = new PromptAttribute(); List<string> quitCommands = new List<string>(); quitCommands.Add("Salir"); quitCommands.Add("Cancelar"); quitCommands.Add("No"); quitCommands.Add("Quiero salir"); quitCommands.Add("Nada"); form.Configuration.Commands[FormCommand.Quit].Terms = quitCommands.ToArray(); return form.Build(); } } 更改为<form onSubmit={this.handleSubmit} ref="threedfrom"和安装部分:

<form onSubmit={this.handleSubmit} ref={(c) => this.threedfrom = c}