• Post Reply Bookmark Topic Watch Topic
  • New Topic

passing value through checkbox?

 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,


i have two files as index and search, i have a checkbox in index and OK button. clicking on "OK" button in index, takes u to serch page,now i want that when i came on search page if checkbox is clicked variable "u" should store value "uid" or else no value. but the value of u always comes out as nothing(if i print u it prints nothing). i tried it with equally also but no result. what shud i do??

1). index.jsp

<input type="checkbox" name="uid">User id


2). search.jsp------>>>
<%
String ui=request.getParameter("uid");

String u;
if(ui=="on"){u="uid";}
else{u="";}
out.prinln(u);
%>
[ December 02, 2005: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sachin,
In Java, you test String equality using the .equals() method. So you can do:

or

I recomment the first one as it is cleaner and easier to read.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!