I'm using two combo boxes, onee and twoo that gets values from database and selected value is to be stored in database. code for setAttribute:
<% String s1= new String(); %>
<select id="onee" name="onee" style="margin-left:400px" required="">
<% while(rs.next()){ %>
<option id="<%=rs.getString(1)%>" name="<%=rs.getString(1)%>" value="<%=rs.getString(1)%>"><%=rs.getString(1)%></option>
<% } %>
</select>
<% s1=request.getParameter("onee");%>
<% request.setAttribute("s1",s1);%>
<%String s2=new String(); %>
<select name="twoo" id="twoo" style="margin-left:200px" required="">
<% while(rss.next()){ %>
<option id="<%=rss.getString(1)%>" name="<%=rss.getString(1)%>" value="<%=rss.getString(1)%>"><%=rss.getString(1)%></option>
<% } %>
</select>
<% s2=request.getParameter("twoo");%>
<% request.setAttribute("s2",s2);%>
code for getAttribute:
String oone=(String)request.getAttribute("s1");
String ttwo=(String)request.getAttribute("s2");
The query:
String sql="insert into choices(ID,One,Two) values ('" + oone + "','" + ttwo + "')";
It only stores null and null
Aucun commentaire:
Enregistrer un commentaire