sum1hor
sum1hor

Reputation: 1

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>

Upvotes: 0

Views: 41

Answers (2)

omrii
omrii

Reputation: 413

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.

Upvotes: 0

nnnnnn
nnnnnn

Reputation: 150020

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();"

Upvotes: 1

Related Questions