Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 10th, 2004, 09:15 AM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default new to jsp...got a checkbox prob

hi,

got a bit of a chkbox prob!

this is the code i have written:

<%
int i;

for (i = 0; i < 1; i++){
int mess = 0;
if (mess >= 0){
mess = mess + 1;

%>
<td><input type="checkbox" name="<%=mess%>"></td>
<%}
}%>

with this code my chkboxes are not incrementing. wen i check the source code after deployed it says 1 for each of the checkboxes.
basically i want each of the checkboxes to have a unqiue value...any ideas on how i can do that?

thanks

seema
ps. if u need more infor ask!

 
Old March 25th, 2004, 10:44 PM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to fernce Send a message via Yahoo to fernce
Default

hi,

your code is good but you over look putting your variable,
your mess ( int mess = 0; ) variable is not suppose to be inside of you looping because every time that your loop turn it back on the top your variable mess would be set again into zero.

I modified you code. Try this

<%
int i;
int mess = 0;
for (i = 0; i < 1; i++){
if (mess >= 0){
mess = mess + 1;

%>
<td><input type="checkbox" name="<%=mess%>"></td>
<%}
}%>



Fernce


 
Old March 26th, 2004, 09:43 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Plus it looks like (forgive me if I'm wrong) only one checkbox will be written with the code you've posted.

----------
---Snib---
----------

<><
 
Old April 8th, 2004, 01:50 AM
Registered User
 
Join Date: Apr 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The reason you got only one checkbox is because you set the limit to 1 in "i<1". If you want to generate ten checkboxes, try this instead:

<%
int param = 10;
for (int i = 0; i < param; i++){
%>
<td><input type="checkbox" name="<%=i%>"></td>
<% } %>



Regards,
kokyan





Similar Threads
Thread Thread Starter Forum Replies Last Post
checkbox checked by default by html:checkbox sachin.tathod Struts 3 December 4th, 2006 03:41 PM
Please Help. mr_newreq.jsp:78: jsp:useBean can't f batken JSP Basics 0 February 22nd, 2006 09:56 PM
JSP Multiple delete Checkbox joepublic JSP Basics 1 February 17th, 2005 02:57 PM
Prob.s with ch.16 of Profes. JSP 2nd Ed. bobbob Pro JSP 1 April 5th, 2004 06:29 AM
Prob.s running Profes. JSP 2nd Ed. ch16 examp.s bobbob JSP Basics 0 February 6th, 2004 09:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.