Hi everyone;
I’ve written the following for some purpose :

<%
Vector v1,v2;
String sql;
String sqlvsp;


sqlvsp= "select distinct(question_text) from question where type = 'UStudent' ";

 
 Vector vc=database.jdbcOneRowQuery(sqlvsp);
	for(int n=0;n<vc.size();n++){
													
 
%>

<table border="0" width="100%">
<tr>
<td colspan="6"><font size="2"><b><%	out.print(n+1); %>)<%	out.print(vc.get(n)); %></b></font>
												
</td>
</tr>

<tr>
<td></td>
<td align="center" width="16%"><font size="2"><b>Very satisfied</b></font></td>
<td align="center" width="16%"><font size="2"><b>Satisfied</b></font></td>
<td align="center" width="16%"><font size="2"><b>Neither</b></font></td>
<td align="center" width="16%"><font size="2"><b>Dissatisfied</b></font></td>
<td align="center" width="16%"><font size="2"><b>Very dissatisfied</b></font></td>

</tr>
<%	

sql = "select option from question where type = 'UStudent'  AND question_text = '"+vc.get(n)+"' ";

 v1=database.jdbcMultipleRowQuery(sql );
 out.print(v1.size());
 String ses="10/11";
 session.setAttribute("ses",ses);


	for(int i=0;i<v1.size();i++){
	v2 = (Vector)v1.elementAt(i);
for(int j=0;j<v2.size();j++){

%>

<input type="hidden" name="q<%=i%>" value="<%out.print(""+v2.get(0)+"");%> ">
<tr>

<td align="left"><font size="2"><b><%out.print(""+v2.get(j)+"");%>
<td align="center"><font size="2"><b><input name="<%=i%>" value="Very satisfied" type="radio">1.</b></font></td> 
<td align="center"><font size="2"><b><input name="<%=i%>" value="Satisfied" type="radio">2.</b></font></td> 
<td align="center"><font size="2"><b><input name="<%=i%>" value="Neither" type="radio">3.</b></font></td> 
<td align="center"><font size="2"><b><input name="<%=i%>" value="Dissatisfied" type="radio">4.</b></font></td> 
<td align="center"><font size="2"><b><input name="<%=i%>" value="Very dissatisfied" type="radio">5.</b></font></td> 
</tr>
<%} }
}
%>
</table>
				<p align="center" style="text-align: center">
				
	<input type="submit" value="Submit">				

</p>

</form><p>


<%

database.jdbcConClose();
database = null;
%>

When I select the options for the first question , it goes smoothly , but when I want to select the options for the second one it would uncheck the options for the first question, and if I select the options for third question , it would uncheck the options for second question, and ….
Is there way that allow me to select the options for each question and it does not effect the others


My regards,

Recommended Answers

All 3 Replies

You should get back to basics of HTML. Simple example here

the radio buttons are inside three loops , can anyone take a look on the code and give suggestion ?

The radio buttons that select/deselect have to by member of same group that is declared through name. As you are giving each radio current value of "i" they cannot be grouped.
Simple example

<form>
    <input type="radio" name="moderator" value="~s.o.s~" checked="checked"/>~s.o.s~<br />
    <input type="radio" name="moderator" value="peter_budo"  />peter_budo<br/>
    <input type="radio" name="moderator" value="Ezzaral" />Ezzaral<br />
    <input type="radio" name="administrator" value="cscgal"/>cscgal<br />
    <input type="radio" name="administrator" value="happygeek" checked="checked"/>happygeek
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.