<form action="myurl"> <button name="test1">test1</button> <button name="test2">test2</button> </form> 

When I click on the buttons, I’ll get the following URLs:

 myurl?test1 myurl?test2 

How to get this type of URL without js

 myurl/test1 myurl/test2 
  • one
    Do you want to change the standard behavior of forms with pure HTML? - smellyshovel

2 answers 2

Based on the @Geslot response, you can also use the formaction attribute:

 <form> <button formaction="myurl/test1">test1</button> <button formaction="myurl/test2">test2</button> </form> 

Example with a field:

 <form target="_blank"> <input type="text" name="q" value="Hello, World!"> <button formaction="//bing.com/search">Bing Search</button> <button formaction="//google.com/search">Google Search</button> </form> 

https://jsfiddle.net/f5po9zck/

     <form action="myurl/test1"> <button>test1</button> </form> <form action="myurl/test2> <button>test2</button> </form>