This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes how to insert multiple check box values into the database using single parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to insert multiple check box values into the database using single parameter" Watch "how to insert multiple check box values into the database using single parameter" New topic
Author

how to insert multiple check box values into the database using single parameter

Hemanth Marathe
Greenhorn

Joined: Mar 01, 2012
Posts: 2
this is my code.....
public ArrayList<InstitutesVO> getFilledforms(String institutionId, HttpServletRequest request) {
// TODO Auto-generated method stub
InstitutesVO vo = new InstitutesVO ();
ArrayList<InstitutesVO> list = new ArrayList<InstitutesVO>();
String priority = request.getParameter("priority");
String courseid = request.getParameter("courseid");
String required = request.getParameter("required");
Iterator it = list.iterator();
PreparedStatement st = null;
Connection conn = null;
//while(it.hasNext()){
try{
conn = getConnection();
// while(it.hasNext()){


//String check =(String) it.next();
//String[] required = request.getParameterValues(check);
//for(int i=0;i<required.length;i++){
st = conn.prepareStatement(Resources.getQuery("INSTITUTIONFORM_CRITERIA"));
st.setString(1, institutionId);
st.setString(2, courseid);
if(required!=null)
st.setString(3, required);
else
st.setString(3, "false");

if(priority!=null)
st.setString(4, priority);
else
st.setString(4, null);
st.executeUpdate();
//}



}catch(SQLException e){
e.printStackTrace();
}

return null;
}

//the above code for inserting....
below is my jsp code.....
<div id="myTable">
<div id="div1" style="float:left;width:450px;" >
<logic:iterate id="collegelist" name="City" scope="request"></logic:iterate>
<table width="100%">
<tr>
<td>
Select Course :
</td>
<td>
<html:select name="collegelist" property="courseid">
<option value="-1"> Select course</option>
<option value="1"> MBA </option>
<option value="2"> MCA </option>
<option value="3"> BE </option>
</html:select>
</td>
</tr>
<tr>
<td>
</td>
<td>
REQUIRED
</td>
<td>
PRIORITY
</td>
</tr>
<tr>
<td width="50%">
Gender :
</td>
<td>
<input type="checkbox" name="required" value="true" onclick="disableText();" id = "collegelist"/>
</td>
<td>
<select name="priority">
<option value="1"> 1</option> <option value="2"> 2</option>
<option value="3"> 3</option> <option value="4"> 4</option>
<option value="5"> 5</option> <option value="6"> 6</option>
<option value="7"> 7</option>
</select>
</td>
</tr>
<tr>
<td width="50%">
Date Of Birth :
</td>
<td>
<input type="checkbox" name="required" value="true" onclick="disableText();" id = "collegelist"/>
</td>
<td>
<select name="priority">
<option value="1"> 1</option> <option value="2"> 2</option>
<option value="3"> 3</option> <option value="4"> 4</option>
<option value="5"> 5</option> <option value="6"> 6</option>
<option value="7"> 7</option>
</select>
</td>
</tr>

<tr>
<td width="50%">
Location :
</td>
<td>
<input type="checkbox" name="required" value="true" onclick="disableText();" id= "collegelist"/>
</td>
<td>
<select name="priority">
<option> 1</option> <option> 2</option>
<option> 3</option> <option> 4</option>
<option> 5</option> <option> 6</option>
<option> 7</option>
</select>
</td>
</tr>
<!--
<tr>
<td width="50%">
Nationality :
</td>
<td>
<input type="checkbox" name="required" value="true" onclick="disableText();" />
</td>
<td>
<select name="expired3">
<option value="priority"> 1</option> <option value="priority"> 2</option>
<option value="priority"> 3</option> <option value="priority"> 4</option>
<option value="priority"> 5</option> <option value="priority"> 6</option>
<option value="priority"> 7</option>
</select>
</td>
</tr>

<tr>
<td width="50%">
Education Qualification :
</td>
<td>
<input type="checkbox" name="required" value="true" onclick="disableText();" />
</td>
<td>
<select name="priority">
<option value=""> 1</option> <option value="priority"> 2</option>
<option value="priority"> 3</option> <option value="priority"> 4</option>
<option value="priority"> 5</option> <option value="priority"> 6</option>
<option value="priority"> 7</option>
</select>
</td>
</tr>

<tr>
<td width="50%">
Marks Obtained :
</td>
<td>
<input type="checkbox" name="required" value="true" onclick="disableText();" />
</td>
<td>
<select name="expired5">
<option value="priority"> 1</option> <option value="priority"> 2</option>
<option value="priority"> 3</option> <option value="priority"> 4</option>
<option value="priority"> 5</option> <option value="priority"> 6</option>
<option value="priority"> 7</option>
</select>
</td>
</tr>
<tr>
<td width="50%">
Entrance Score :
</td>
<td>
<input type="checkbox" name="required" value="true" onclick="disableText();" />
</td>
<td>
<select name="expired6">
<option value="priority"> 1</option> <option value="priority"> 2</option>
<option value="priority"> 3</option> <option value="priority"> 4</option>
<option value="priority"> 5</option> <option value="priority"> 6</option>
<option value="priority"> 7</option>
</select>
</td>
</tr>

--><td>
<input type="submit" name="Submit" value="Submit">

</td>


</table>
</div>
</div>
</div>
</form>
<!--</html:form>
--></div>
</div>
</div>

//below the database query..'
INSTITUTIONFORM_CRITERIA = insert into institution_selection_criteria (_Institution_Id,_Course_Id,_Required,_Priority) values(?,?,?,?)

please help me out....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to insert multiple check box values into the database using single parameter
 
Similar Threads
Resetting values of table cells in Javascript
Space not releasing on toggle of divs
Redirecting a page
Removing a row from a table using JavaScript not working
Doubts in jsp