button with link inside the form

1

I have a form with 2 button inside. 1 and the submit and the other I need to put a link on it. When clicked it can not send form and call the link.

Follow my code:

<form name='form' method=post action='link' enctype='multipart/form-data'>

   <button type='submit'>

   <button> link

<form>
    
asked by anonymous 05.05.2016 / 19:37

1 answer

2

Within a <form> buttons without% set% behave as type . Then you need to have type="submit" .

To make it redirect to another page you can do inline like this:

<form name='form' method=post action='link' enctype='multipart/form-data'>
   <button type='submit'>Enviar</button>
   <button type="button" onclick="window.location='http://google.com'">link</button>
</form>

or with an event handset like this:

var btn = document.querySelector('button[type="button"]');
btn.addEventListener('click', function(){
    window.location='http://google.com';
});

Having HTML only:

<button type="button">link</button>
    
05.05.2016 / 19:49