java - How to make multiple dependent TextBox on Dropdown value from database in jsp -
please need how make dependent textbox on dropdown value come form database in jsp. below code work fine 1 textbox.but don't know how make multiple dependent textbox.so me.
thanks.
tender.jsp: <% connection conn = null; statement st = null; resultset rs = null;* conn = jdbcconnectionutil.getconnection(); if(conn != null) { try { string woodsql = "select fsa_wood_type_master_wood_type, fsa_wood_type_master_wood_weight,fsa_wood_type_master_wood_length,fsa_wood_type_master_wood_width,fsa_wood_type_master_wood_standard_rate fsa_wood_type_master"; st = conn.createstatement(); rs = st.executequery(woodsql); } catch(sqlexception e) { e.printstacktrace(); } } %> <td> <select id="woodtype" onchange="populatewoodid();"> <%while(rs.next()){ %> <option value="<%=rs.getstring(1) %>"><%=rs.getstring(2) %></option> <%} %> </select> <input id="woodheight" type="text" value="" /> </td>
}
javascrip: function populatewoodid(){ var selectbox = document.getelementbyid('woodtype'); /* selected value of dropdown */ var woodheight = selectbox.options[selectbox.selectedindex].value; /* selected value set input field */ document.getelementbyid('woodheight').value = woodheight; }
change option tag line :
<option value='<%=rs.getstring(1)+"#"+rs.getstring(2)+"#"+rs.getstring(3)+"#"+rs.getstring(4)+"#"+rs.getstring(5) %>'><%=rs.getstring(2) %></option>
and in javascript :
function populatewoodid(){ var selectbox = document.getelementbyid('woodtype'); /* selected value of dropdown */ var woodprop = selectbox.options[selectbox.selectedindex].value; /* selected value set input field */ var splitval=woodprop.split("#",5); document.getelementbyid('woodheight').value = splitval[0]; document.getelementbyid('woodheight1').value = splitval[1]; document.getelementbyid('woodheight2').value = splitval[2]; document.getelementbyid('woodheight3').value = splitval[3]; document.getelementbyid('woodheight4').value = splitval[4]; //five different textboxes }
Comments
Post a Comment