title: how to pass checkbox value(checked/unchecked) to controller as href parameter in jsp
body: <p>I am a beginner in jsp.I want to get data from database and show checked on a checkbox depending on db value i.e. 0 or 1.This is working for me.But I also want o that when I check or uncheck the checkbox it will reset value and pass it to controller as a href parameter.
  here is my jsp:</p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ page session="false" %&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Investor Account&lt;/title&gt;
  &lt;/head&gt;
  
      &lt;body&gt;
  
    &lt;script type="text/JavaScript"&gt;
              function updateCheck(){
  
                  if(document.getElementById('chk').checked){
                       document.getElementById('chk').value = 1;
                       location.href=""
                       alert(document.getElementById('chk').value);
  
  
  
                   }
                  else{
                        document.getElementById('chk').value = 0;
                        alert(document.getElementById('chk').value);
  
  
                  }
  
              }
  
  &lt;/script&gt;
          &lt;div align="center"&gt;
              &lt;h1&gt;Investor Account List&lt;/h1&gt;
  
              &lt;table border="1"&gt;
                  &lt;th&gt;ID&lt;/th&gt;
                  &lt;th&gt;Investor Code&lt;/th&gt;
                  &lt;th&gt;Investor Name&lt;/th&gt;
                  &lt;th&gt;SMS Subscriber&lt;/th&gt; 
                  &lt;th&gt;Action&lt;/th&gt;         
                  &lt;c:forEach var="investorAcc" items="${listInvestorAcc}" varStatus="st"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;${st.index + 1}&lt;/td&gt;
                      &lt;td&gt;${investorAcc.investor_code}&lt;/td&gt;
                      &lt;td&gt;${investorAcc.investor_name}&lt;/td&gt;
                      &lt;td&gt; &lt;input type="checkbox" id="chk" name="chkSms" value=  &lt;c:if test="${investorAcc.sms_sub==1}"&gt;1&lt;/c:if&gt; onclick="updateCheck();"
                      &lt;c:if test="${investorAcc.sms_sub==1}"&gt;checked="checked"&lt;/c:if&gt;/&gt;
  
                    &lt;td&gt;
  
                        &lt;a href="updateInvestorAcc?id=${investorAcc.id}&amp;chkSms=&lt;c:if test="${chkSms==1}"&gt;1&lt;/c:if&gt;"&gt; Update &lt;/a&gt;
                     &lt;/td&gt;
  
                  &lt;/tr&gt;
  
                  &lt;/c:forEach&gt;             
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>