• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Textfield with Four Checkbox Help Needed

 
phillip atienza
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

Please help me..

how can I code this..

a single texfield with four checkbox...

String usergroupname = request.getParameter("usergroupname");
String checkbox = request.getParameter("checkbox");
String checkbox2 = request.getParameter("checkbox2");
String checkbox3 = request.getParameter("checkbox3");
String checkbox4 = request.getParameter("checkbo4");


String query="";
ResultSet rs=null;

boolean flag=true;

if (request.getParameter("addusergroup") != null )
{
if (usergroupname.trim().equals(""))
{
out.println("<li>User Group Name field should not be blank!</li>");
flag=false;
if (request.getParameter("checkbox") != null )
{
try
{
query ="insert into cmr_ups.dbo.[usergroup] (usergroup_name , privileges )"+ "values('"+usergroupname.trim()+"','"+checkbox+"')";
}

}

if (request.getParameter("checkbox2") != null )
{
try
{
query ="insert into cmr_ups.dbo.[usergroup] (usergroup_name , privileges ) "+
"values('"+usergroupname.trim()+"','"+checkbox2+"')";
}


if (request.getParameter("checkbox3") != null )
{
try
{
query ="insert into cmr_ups.dbo.[usergroup] (usergroup_name , privileges ) "+
"values('"+usergroupname.trim()+"','"+checkbox3+"')";
}


if (request.getParameter("checkbox4") != null )
{
try
{
query ="insert into cmr_ups.dbo.[usergroup] (usergroup_name , privileges ) "+
"values('"+usergroupname.trim()+"','"+checkbox4+"')";
}

}




if(flag)
{
try
{
query ="insert into cmr_ups.dbo.[usergroup] (usergroup_name ) values " + "('"+usergroupname.trim()+"','"+checkbox+"','"+checkbox2+"','"+checkbox3+"','"+checkbox4+"')";


statement.executeUpdate(query);
out.println("<li>User Group Name Successfully Added!</li>");

}
catch(Exception e)
{
out.println(e);
}
}

}
%>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what's your question?

And, please use UBB code tags to preserve the formatting of your code. Few people are going to take the time to try and decipher pages of unformatted code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic