I can’t get my css button to submit. the form directs to the correct page, but nothing gets submitted. any ideas?
echo "<form action=\"submit_something.php\" id=\"submit_x\" method=\"post\">
<input type=\"hidden\" name=\"submit_value\" value\"10\"/><div id=\"button\">
<a href=\"javascript:;\"onclick=\"javascript:document.getElementById('submit_something').submit()\">buttonvalue</a>
</div></div></form>"
update2:
echo "<form action=\"submit_something.php\" id=\"submit_x\" method=\"post\">
<input type=\"hidden\" name=\"submit_value\" value\"10\"/><div id=\"button\">
<a href=\"javascript:;\"onclick=\"javascript:document.getElementById('submit_x').submit()\">buttonvalue</a>
</div></div></form>"
update3:
I tried this instead:
css:
#btn {font-weight:bold}
html:
<form action="submit_something.php" id="submit_x" method="post">
<input type="submit" value="button" id="#btn">
</form>
The button doesn’t get styled. I tried differentcss parameters, but the submit button doesn’t get styled. Any ideas?
You’re attempting to submit an element with the ID
submit_something, but your form actually has the IDsubmit_x, so the form won’t submit. Also, you shouldn’t includejavascript:into event handler code likeonclick; this is only needed when you want to execute Javascript code in something like ahref.I don’t recommend submitting your form using Javascript by the way, avoid it if you can. Using basic HTML functions like submit buttons where possible can prevent a lot of trouble, for example with usability.