简体   繁体   中英

Div not submitting form

i've tried a lot of different methods to get this done, however none actually worked any suggestions? Thanks

<div name="login" class="blue_button" onclick="
document.getElementById("form").submit();"><div class="blue_button_text noselect">Login</div></div>

The problem is that you've tried to use double-quote characters for your element attributes and for the string literal in your JS. So your onclick attribute is read as onclick="document.getElementById(" with the form").submit();" part left over.

Change the inner double-quote characters to single-quote characters and it will work (assuming you have a form with id="form" ):

onclick="document.getElementById('form').submit();"

Are you sure that you've declared the form with the <form> tag? Also, try to change the tag of the submit button from <div> to <button> or <input> . Makes more sense semantically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM