Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button post HTML

I need to use a button without using a form. How do I make it send post data to the browser?

I am using:

<button style="height: 100px; width: 300px" onClick="parent.location='form1.php'" >Fill survey</button>
like image 731
user434885 Avatar asked Jan 12 '11 07:01

user434885


1 Answers

You'll need to create a form in JavaScript, then submit it. Look at this code

The HTML

<button type="button" onclick="proceed();">do</button> 

The JavaScript code

function proceed () {
    var form = document.createElement('form');
    form.setAttribute('method', 'post');
    form.setAttribute('action', 'http://google.com');
    form.style.display = 'hidden';
    document.body.appendChild(form)
    form.submit();
}
like image 161
Xavier Barbosa Avatar answered Oct 15 '22 17:10

Xavier Barbosa