Passing form parameter value
Posted on 2005-03-07
let's say I have a form which contains a checkbox (which initially is checked and its value is retrieved from a bean) and a link to the next page. for example
<form name="myForm" method="post" action="/MyProject/MyController">
<input type="checkbox" name="myCheckbox" <%=myBean.getIfCheckedOrNot()%>>
<!-- notice that the checkbox is set to 'checked' initially -->
<a href="someOtherTartget" > Click to Relocate </a>
<input type="submit" value="submit" onclick='test(this.form)';>
If I click on 'Click to Relocate' link....which will take me to some controller....how can I pass the value of the checkbox (checked or not checked) to that class? Please note, i'm not using the submit button, (that would be easy since i would be using the form elements and i could just do: request.getParameter("myCheckbox") ) instead i'm clicking on the link....so my initial approach was to use queryString and append the value of the checkbox to the end of the url. but the value of the checkbox is dynamic (user can check it or uncheck it in the current screen)...so queryString will not work...
The main idea is that I have to use a link to jump to the next page....and not a submit button....and i need to pass the current value of the checkbox.