Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
class="form-search">
<input style="color: black; background: rgba(255,255,255,0.5); padding: 15px; font-size: 18px;"
type="text"
name="search"
class="input-medium search-query">
<div class="button1" onClick="document.forms["search-form"].submit();">
<a href="#">
<img alt="" src="/img/buttons/icon1.png" />
</form>
The form does not submit when the div is clicked. Could someone point out the problem?
thanks. I've been trying this for an hour at least.
The
a href
is needed to keep the styling, but even if I remove it and left with just the icon, the submit doesn't work; nor does it work if I apply the
onclick
to the image.
You can't just use quotes in quotes. Use single quotes to fix:
<form name="search-form" id="search-form" action="php.php" class="form-search">
<input style="color: black; background: rgba(255,255,255,0.5); padding: 15px; font-size: 18px;" type="text" name="search" class="input-medium search-query">
<div class="button1" onClick="document.forms['search-form'].submit();">
<a href="#">
<img alt="" src="img/buttons/icon1.png" />
</form>
It may not have anything to do with the error (or maybe it does, due to invalid html?), but you should add an end-tag to your input
tag, right at then end here:
<input style="color: black; (... etc) "
type="text"
name="search"
class="input-medium search-query" />
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.