what do <form action=“.”>

问题: I have a basic question. I cannot find an explanation of form action="." despite searching for on google, www.w3schools.com, etc... Anyone know what the . action means fo...

问题:

I have a basic question. I cannot find an explanation of form action="." despite searching for on google, www.w3schools.com, etc...

Anyone know what the . action means for forms? Is it specific to Django? Bootstrap?

Code below:

{% extends "Blog.html" %}
{% block blog%}
  <h1>Create an account</h1>
  <p>Please, sign up using the following form:</p>
  <form action="." method="post">
    {{ user_form.as_p }}
    {% csrf_token %}
    <p><input type="submit" value="Create my account"></p>
  </form>
{% endblock %}

回答1:

Form Action attribute specifies where to send the form-data when a form is submitted

Possible accepted values:

  1. An absolute URL: points to another web site (like action="http://www.example.com/example.htm")
  2. A relative URL - points to a file within a web site (like action="example.htm")

in your case of action="." you are pointing to current url/file/directory. So it will reload the same page on form submission.


回答2:

Normally, the action attribute in a form specifies where the data should go to, for example a processing file: action="proces.php".

Sometimes, action="#" or action="." is used to reload the page and process the data on the same page.

Basically, it just submits the form to the same page.


回答3:

It reloads the current page, but with new data.

  • 发表于 2019-02-14 01:00
  • 阅读 ( 216 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除