Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
You have to be odd to be #1 - Seuss. An odd little ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic