我試圖將用戶重定向到當前網站上的一個新頁面,一旦表單提交給另一個url。HTML創建onsubmit重定向
我看了這麼多的董事會,找出最好的方法。我無法修改發佈的目標網址,因此我認爲onsubmit函數最適合將用戶重定向到另一個頁面。但由於某種原因,我無法弄清楚如何讓重定向工作。
下面是代碼,我現在所擁有的:
<form method=post onSubmit="window.location.href='https://thankyoupage.com/'action="https: //urltopostto.com?encoding=UTF-8"><input type="hidden" name="inquiry_from" value="website" />
<fieldset><legend style="display: inline !important;">We Can't Wait to Hear from You</legend>
<div><label for="first_name">First Name*</label>
<input id="first_name" type="text" maxlength="40" name="first_name" required="" size="20" /></div>
<div><label for="last_name">Last Name*</label>
<input id="last_name" type="text" maxlength="80" name="last_name" required="" size="20" /></div>
<div><label for="email">Email*</label>
<input id="email" type="email" name="email" required="" size="20" /></div>
<div><label for="phone">Phone*</label>
<input id="phone" type="tel" name="phone" placeholder="(111) 111-1111" required="" size="20" /></div>
</fieldset>
<fieldset><legend>Company Information</legend>
<div><label for="company">Organization Name*</label>
<input id="organization" type="text" maxlength="40" name="organization" required="" size="20" /></div>
<div>
</fieldset>
<fieldset>
<div><label for="Inquiry">Can you provide us additional information?</label>
<textarea id="inquiry" maxlength=""256" name="inquiry" rows="6" wrap="soft"></textarea> </div>
<section><input type="submit" value="Submit" /></section></fieldset>
</form>
我不知道它是否有所作爲,但您的onSubmit在開始時有一個開放的雙引號,但在結尾處沒有關閉。它看起來像是將action作爲onSubmit函數的一部分來讀取。 – Joel