html select change to make JSP page forward keeping the exsting field value
843836Jun 20 2005 — edited Aug 21 2005Hello, All,
I am trying to make the change of a selection box in HTML form to reload the page and populate the second selection box based on the value in the first selection box. The content of the second selection box is from database....
i used a javascript funtion and called it by the onChange(), the onChange redirect the page to the same page. However all my previous input is lost and the second selection box is not populated based on the first selection box.
The question is how do I keep the current input and reload the page based on the change of a selection box?
Please help..
Thanks..
Here is the code
<script language=javascript type="text/javascript">
function forward(){
location.href="trdCapDetail.jsp";
}
</script>
<select name=vehicle onChange="forward()">
<%for(int i = 0; i < Vehicle.getAll().size(); i++){
Vehicle vehicle = (Vehicle)(Vehicle.getAll().elementAt(i));
out.write("<option value=" + vehicle.getKey()+" >" + vehicle.getCode() + "</option>");
}
%>