Ajay Jain
Ajay Jain

Reputation: 33

Html form's action attribute

My html form is:

<form action='update/'>
   some code here ...
</form>

When the form is submitted at a url, 127.0.0.1/account/1, it sends the request to 127.0.0.1/account/update.

I want it to send the request to 127.0.0.1/account/1/update.

(I am using Django)

Thank you

Upvotes: 0

Views: 139

Answers (1)

Quentin
Quentin

Reputation: 943207

To resolve a relative path:

  1. Take the base URL
  2. Remove everything after the path
  3. Remove everything after the last / in the path
  4. Append the relative path

You seem to want it to skip step 3, but you can't can't change the way that works.

So your options:

  • Change the current page's URL to /account/1/
  • Change the action's path to 1/update
  • Change the action's to an absolute path (/account/1/update)
  • Write a JavaScript submit event handler that converts the action to an absolute path using your own rules.

I don't recommend the last option.

Upvotes: 1

Related Questions