简体   繁体   English

PHP的回声提交按钮错误

[英]php echo submit button error

I can't get my css button to submit. 我无法提交CSS按钮。 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: 更新2:

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: update3:我改用此方法:css:

#btn {font-weight:bold}

html: 的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. 我尝试了differentcss参数,但是提交按钮没有样式。 Any ideas? 有任何想法吗?

You're attempting to submit an element with the ID submit_something , but your form actually has the ID submit_x , so the form won't submit. 您正在尝试提交ID为submit_something的元素,但是您的表单实际上具有ID submit_x ,因此表单不会提交。 Also, you shouldn't include javascript: into event handler code like onclick ; 另外,您不应该将javascript:包含在事件处理程序代码中,例如onclick ; this is only needed when you want to execute Javascript code in something like a href . 仅当您要在类似href代码中执行Javascript代码时才需要使用此代码。

I don't recommend submitting your form using Javascript by the way, avoid it if you can. 我不建议您使用Javascript提交表单,如果可以的话,请避免使用。 Using basic HTML functions like submit buttons where possible can prevent a lot of trouble, for example with usability. 尽可能使用诸如提交按钮之类的基本HTML功能可以避免很多麻烦,例如可用性。

Use the input type of image instead, or style your submit button, instead of this unmaintainable nastiness you have now. 改用图像的输入类型,或设置提交按钮的样式,而不是现在这种无法维护的麻烦。

<input type="image" src="myimage.png" />

The image input behaves the same way as a regular submit button. 图像输入的行为与常规提交按钮相同。

Or, you can style an actual submit button appropriately, with most of the same styles as your anchor currently. 或者,您可以为实际的提交按钮设置适当的样式,大多数样式与当前锚点相同。 For more info, see http://www.456bereastreet.com/lab/styling-form-controls-revisited/submit-button/ 有关更多信息,请参见http://www.456bereastreet.com/lab/styling-form-controls-revisited/submit-button/

use 采用

<input type="submit" value="button" id="btn">

instead of 代替

<input type="submit" value="button" id="#btn">

to apply the style with id btn. 应用ID为btn的样式。

CSS 的CSS

#btn {font-weight:bold}

and your php to print the form 和你的PHP打印表格

echo "<form action=\"submit_something.php\" id=\"submit_x\" method=\"post\">
<input type=\"hidden\" name=\"submit_value\" value=\"10\"/><div id=\"button\">
<a href='' onclick=\"document.getElementById('submit_x').submit();return false;\">buttonvalue</a>
</div></div></form>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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