I am a very beginner in javascript and I would like to change a single input value when the user selects an option with a form, thhen submit it to the same page.
here is the Html code:
<form id="form" action="thispage.jsp" method="post">
<input id="action_type" type="hidden" name="action_type" value="firstAction" />
<table class="choose">
<tr>
<td>Choose your test</td>
<td><select id="select_test" name="test_name">
<option value="test0"></option>
<option value="test1"></option>
</select></td>
</tr>
</table>
And the javascript function:
form = document.getElementById("form");
action = document.getElementById("action_type");
select = document.getElementById("select_test");
select.onchange = function() {
action.setAttribute("value", "otherAction");
form.submit();
}
And this returns an Exception, what is wrong with this code ?