Javascript 在React中将表单提交到Google表单时出现错误400
我在我的网站上有一个表单,内容将保存到谷歌表单中。它在今天早些时候起作用了,但在提交时突然出现了一个错误(错误代码400)。我不知道为什么会这样。它在一小时前起作用了。也没有更改表单中的任何代码。我删除了上次成功提交和第一次错误之间的回复。这可能是错误的原因吗?谢谢你的帮助Javascript 在React中将表单提交到Google表单时出现错误400,javascript,reactjs,forms,google-forms,Javascript,Reactjs,Forms,Google Forms,我在我的网站上有一个表单,内容将保存到谷歌表单中。它在今天早些时候起作用了,但在提交时突然出现了一个错误(错误代码400)。我不知道为什么会这样。它在一小时前起作用了。也没有更改表单中的任何代码。我删除了上次成功提交和第一次错误之间的回复。这可能是错误的原因吗?谢谢你的帮助 const handleFormSubmit = () => { setSubmitted(true) setName('') setEmail('')
const handleFormSubmit = () => {
setSubmitted(true)
setName('')
setEmail('')
setAge('')
}
const onIframeLoad = () => {
if (submitted === true) {
history.push("/bli-medlem")
}
}
<form onSubmit={handleFormSubmit} method="POST" target="hidden_iframe" action="https://docs.google.com/forms/d/18TBcc5oK0i0IEkMWJmRnljzaPSx8AjNR9Rseo8OkgKw">
<ul className="form">
<li className="form-element">
<label htmlFor="entry.2026036521">Namn</label>
<input
className="text-input"
name="entry.2026036521"
type="text"
value={name}
onChange={e => setName(e.target.value)}
required={true}
/>
</li>
<li className="form-element">
<label htmlFor="entry.2122300620">E-post</label>
<input
className="text-input"
name="entry.2122300620"
type="email"
value={email}
onChange={e => setEmail(e.target.value)}
required={true}
/>
</li>
<li className="form-element dropdown">
<label htmlFor="entry.1689165674">Alder</label>
<select name="entry.1689165674" value={age} onChange={e => setAge(e.target.value)}>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
</select>
</li>
<li className="form-element">
<label htmlFor="training-choice">Vil du vera med på organiserte treningar i nokre av spela med tilbyr?</label>
<div className="choice">
<p>Ja</p>
<input
name="entry.737229839"
type="radio"
value="Ja"
onChange={() => setValue("Ja")}
/>
</div>
<div className="choice">
<p>Nei</p>
<input
name="entry.737229839"
type="radio"
value="Nei"
onChange={() => setValue("Nei")}
/>
</div>
</li>
<label style={{fontSize: "24px", fontWeight: 'bold', marginTop: '40px'}} htmlFor="entry.1182933035">Kva for nokre spel?</label>
<li className="form-element-choice">
<p>Fortnite</p>
<input
name="entry.1182933035"
type="checkbox"
value="Fortnite"
/>
</li>
<li className="form-element-choice">
<p>Counter-Strike: Global Offensive</p>
<input
name="entry.1182933035"
type="checkbox"
value="Counter-Strike: Global Offensive"
/>
</li>
<li className="form-element-choice">
<p>Rocket League</p>
<input
name="entry.1182933035"
type="checkbox"
value="Rocket League"
/>
</li>
<li className="form-element">
<input className="submit-button" type="submit" value="Submit"/>
</li>
<iframe name="hidden_iframe" style={{display: "none"}} onLoad={onIframeLoad}></iframe>
</ul>
</form>
const handleFormSubmit=()=>{
setSubmitted(真)
集合名(“”)
设置电子邮件(“”)
设置(“”)
}
const onIframeLoad=()=>{
如果(已提交===true){
历史推送(“/bli medlem”)
}
}
-
纳姆
setName(e.target.value)}
必需={true}
/>
-
电子邮政
setEmail(e.target.value)}
必需={true}
/>
-
桤木
设置(如目标值)}>
12
13
14
15
16
17
18
-
维拉医学院,我是诺克雷和斯佩拉医学院的组织者?
嗯
setValue(“Ja”)}
/>
内
setValue(“Nei”)}
/>
nokre spel的千伏安?
-
福特尼特
-
反击:全球攻势
-
火箭联盟
-
问题是在提交完成之前,我将每个输入字段的状态设置为'
。我搬走了
setName('')
setEmail('')
setAge('')
问题解决了