【问题标题】:is there any way to remove "action" attribute from "Form" tag and still able to send the form?有没有办法从“表单”标签中删除“动作”属性并且仍然能够发送表单?
【发布时间】:2021-04-18 03:16:14
【问题描述】:

如何去除form标签中的action属性。我想找到一种方法将表单提交到现有的“process_login.php.php”,而无需操作属性。请不要使用任何 JavaScript。

<!DOCTYPE html>
<html>
<head>
  <title>Login Form</title>
</head>
<body>
<h1>Login Form</h1>
<hr>
<form action="http://corneyx.com/process_login.php" method="post">
  <table border="1" cellpadding="10">
    <tr>
      <td>Username:</td>
      <td><input type="text" name="username" required></td>
    </tr>
    <tr>
      <td>Password:</td>
      <td><input type="password" name="password" required></td>
    </tr>
  </table>
<hr>
<!-- put your buttons here -->
<input type="hidden" name="matricnum" value="???????">
<input type="submit" name="login_form" value="Login">
<input type="reset">
</form>
</body>
</html>

【问题讨论】:

  • 你不能。为什么不想用javascript,为什么要去掉action标签?

标签: html forms tags action


【解决方案1】:

???

我了解到有些人想从&lt;form&gt; 标记中删除操作属性。

但是,不允许使用 JavaScript??

对不起,只是没办法。它只是不是这样设计的。

如果您有兴趣研究普通 HTML &lt;form&gt; 以及您可以用它们做什么,这里是一个关于 &lt;form&gt; 标记的 W3.org 链接。

除非您创建自己的浏览器允许这样做,但老实说,这无论如何都会破坏目的。

【讨论】:

  • 这其实是一道测试题。我不想那样做。他们坚持认为有办法
【解决方案2】:

可以将 action 属性留空并使用 ajax,但如果您不想使用 JavaScript,则会卡住

【讨论】:

  • 这其实是一道测试题。
  • 嗯,如果您确实找到了解决方案,请告诉我,但据我所知,您不可能使用onSubmit="function()",但这需要 js。您可能误读了问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-13
  • 1970-01-01
  • 2022-01-17
相关资源
最近更新 更多