[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

html table array checkboxes

Posted on 2005-04-20
9
Medium Priority
?
296 Views
Last Modified: 2010-04-01
am developing in JSP but need the following solution done in Javascript or java
What I need:

I have a html table which is created from a sql statement when the page loads
'select * from enrolle'

The table builds out to the following format:

    Id    CourceID    
    1      A            
    2      BC            v  
    3      CC            
    4      D              v
    5      F2            

etc

The v is a checkbox (or button if better), which the user stores the CourceID  for that row.

I want to be able to select the checked checkboxes, and the corresponding table elements for that row will be stored in java variables for that row.

any idea?


Thanks
0
Comment
Question by:gla
  • 5
  • 4
9 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 13822926
what's the problem?

Just assign them a value based on the row, and read the values out again...

ie:

<%
    String[] selected = request.getParameterValues( "check" ) ;
    for( int i = 0 ; i < selected.length ; i++ )
        out.println( selected[ i ] + " WAS SELECTED</br>" ) ;
%>
<form>
    <table>
       <tr>
          <td><input type="text" name="row0" value="whatever"/></td>
          <td><input type="checkbox" name="check" value="0"/></td>
       </tr>
       <tr>
          <td><input type="text" name="row1" value="blah"/></td>
          <td><input type="checkbox" name="check" value="1"/></td>
       </tr>
       <tr>
          <td><input type="text" name="row2" value="heh"/></td>
          <td><input type="checkbox" name="check" value="2"/></td>
       </tr>
    </table>
    <input type="submit" value="POST!"/>
</form>
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 2000 total points
ID: 13822934
More complex that this?

<html>
<head><title>Form1</title></head>
<body>

<form name="form1" action="form2.jsp">

Course A<input type="checkbox" name="1" value="A"><br>
Course BC<input type="checkbox" name="2" value="BC"><br>
Course CC<input type="checkbox" name="3" value="CC"><br>
Course D<input type="checkbox" name="4" value="D"><br>
Course F2<input type="checkbox" name="5" value="F2"><br>

<input type="Submit" value="Submit">
</form>

<body>
</html>


<%@page import="java.util.Enumeration" %>
<%
session.setAttribute("one" , request.getParameter("1"));
session.setAttribute("two" , request.getParameter("2"));
session.setAttribute("three" , request.getParameter("3"));
session.setAttribute("four" , request.getParameter("4"));
session.setAttribute("five" , request.getParameter("5"));
%>

<html>
<head><title>Form2</title></head>
<body>

<UL>
<%
    Enumeration e = session.getAttributeNames();
    while (e.hasMoreElements()) {
       String name = (String)e.nextElement();
       String value = session.getAttribute(name).toString();  

%>
<LI><%= name %>:
<%= value %>
</LI>
<%
}
%>
</UL>



<body>
</html>
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13822937
Aargh, the mental flow has been reversed!!!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 13822938
you could just use one name for all checkboxes ;-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13822944
>>  Aargh, the mental flow has been reversed!!!

hahahaha :-D
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13822964
>> you could just use one name for all checkboxes
Yes, but it makes a nicer example (and a little easier to follow, but that was probably blown out of the water when I used the Enumeration to output them!)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13823022
>> but that was probably blown out of the water when I used the Enumeration to output them!)

lol! :-D
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13823150
Thanks :-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13823191
:-( Looks like the enumeration and multiple checkbox names method won :-(
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question