function switchas() {
var oldFoo = document.getElementById('foo');
var oldBar = document.getElementById('bar');
oldFoo = oldFoo.value;
oldBar = oldBar.value;
document.myForm.elements["foo"].value = oldFoo;
document.myForm.elements["bar"].value = oldBar;
// Uncomment following line for autosubmit
// document.myForm.submit();
}
And the HTML looking like this:
<a href="#" onclick="switchas();">Switch</a>
<form action="#" method="post" name="myForm">
<input id="foo" name="foo" value="foo" type="text">
<input id="bar" name="bar" value="bar" type="text">
</form>
No comments:
Post a Comment