function buildElement(tagName, props) {
var element = document.createElement(tagName);
for (var propName in props) element[propName] = props[propName];
return element;
}
function submit(link, props) {
var form = buildElement('form', {method: 'post', action: link});
for (var propName in props) form.appendChild(
buildElement('input', {type: 'hidden', name: propName, value: props[propName]})
);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
submit('index.php', {name: 'Ivan', year: '25'});