title: change input value with change in select menu options
body: <p>This is javacript for getting same category_name in input box as in select box
  but i dont know the code for getting my category_id and category_desc for the same</p>
  
  <p><code>&lt;script type="text/javascript"&gt;
              function filltxtbox(){
                  var e = document.getElementById("sel");
                  var strUser = e.options[e.selectedIndex].text;
                  document.getElementById("txtselname").value=strUser;
                  document.getElementById(defcatid).value
              }
          &lt;/script&gt;
  </code></p>
  
  <p>This is the jsp page's code with which i set the default values but i want these values to change a s the select option value changes, if u need any other information please let me know.</p>
  
  <pre><code>                &lt;%! Connection con = null;%&gt;
                  &lt;%! Statement st = null;%&gt;
                  &lt;%! ResultSet rs = null;%&gt; 
                  &lt;%
                      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                      con = DriverManager.getConnection("jdbc:derby://localhost:1527/mydb1", "mydb", "mydb");
                      st = con.createStatement();
                      rs = st.executeQuery("SELECT category_id, category_name FROM Category");
                      con.setAutoCommit(false);
                  %&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          CATEGORY NAME
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;%-- using select tag  --%&gt;
                          &lt;select id="sel" onchange="filltxtbox()"&gt;
                              &lt;%
                                  String catname = null;
                                  int catid = 0;
                                  while (rs.next()) {
                                      catname = rs.getString(2);
                                      catid = rs.getInt(1);
                                      out.println("&lt;option value=" + catid + "&gt;" + catname + "&lt;/option&gt;");
                                  }
                              %&gt;
                          &lt;/select&gt;
                      &lt;/td&gt;
                      &lt;jsp:setProperty name="category" property="*"/&gt;
                      &lt;%--// category_id input  --%&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          CATEGORY ID
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;%  rs = st.executeQuery("SELECT category_id FROM Category");
                              if (rs.next()) {
                                  int defcatid = rs.getInt(1);
                                  out.print("&lt;input  type = 'text' name = 'category_id' id='txtselid' value ='" + defcatid + "' size = '30'/&gt;  ");
                              }
                          %&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;%--// category_name input  --%&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          CATEGORY NAME
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;%  rs = st.executeQuery("SELECT category_name FROM Category");
                              if (rs.next()) {
                                  String defcatname = rs.getString(1);
                                  out.print("&lt;input  type = 'text' name = 'category_name' id='txtselname' value ='" + defcatname + "' size = '30'/&gt;  ");
                              }
                          %&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;%--// category_desc input  --%&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          CATEGORY DESCRIPTION
                      &lt;/td&gt;
                      &lt;td&gt;&lt;%
                          rs = st.executeQuery("SELECT category_desc FROM category");
                          if (rs.next()) {
                     String defcatdesc = rs.getString(1);
                     out.print("&lt;textarea name='category_desc' rows='10' cols='50' &gt;" +defcatdesc + "&lt;/textarea&gt;");
  </code></pre>
  
  <p>}%>`                 </p>