aspose file tools*
The moose likes JSP and the fly likes print database values with radio button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "print database values with radio button" Watch "print database values with radio button" New topic
Author

print database values with radio button

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
I need to show all database values in a jsp with radio button for each row.
i can retreve database value.but how to attache radio button to it when showing it in a jsp?
Goutham Pallipati
Greenhorn

Joined: Aug 13, 2008
Posts: 20
Is your requirement to show all radio buttons as one set. then hee is some sample code.

<% while(rs.next()) { %>
<input type="radio" NAME="heyou" value="<%=rs.getString(1)%>"><%=rs.getString(1)%>

<%}%>

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
in database row there are 6 colums.
user need to select two colums.
user must selecl zone and payment type.
can you give me example code for with two radio button for onerow?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(Minus the scriptlet, plus a DTO, change the names to be what you need, plus whitespace and indentation to show structure and enhance clarity.)
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Do not use scriptless in JSP! And that rs there makes baby Jesus cry!

Samanthi perera wrote:in database row there are 6 colums.
user need to select two colums.
user must selecl zone and payment type.
can you give me example code for with two radio button for onerow?


I don't understand your problem, what do you want to show in the browser? A table with different columns and some of them selectable? Remember that with a radio type you can only select one element of the group. Maybe you should think on using checkboxes. Explain better what you want.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
i need to show the zone and the type of the trip.
there are many zone types.
and there are there types of trips
ex
zone type1 type2 type3
1
2
3
4

user shuold be able to select zone and the one type of any type.
how to use radio button to do this?
is there any other way than radio button.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you're *showing* values, just display the zone.

If you need to *select* a single value, create a radio button group with the appropriate labels and values.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
no it is not a single value.I need to select zone and type both.so there should be two radio button atleast.

zone type1 type2 type3
@ 1 @ @ @
@ 2 @ @ @
.......................................
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
What I understand is that you have different zones and different ways of paying and you can select one of the zones and trip type, is that correct?

Ex:

zone1 | zone2 | zone3 | ... | zoneN
trip1| trip2 | trip3 | ... | tripN

so user can select to go to zone3 and trip1, or zone2 and tripN.

If I am correct then you should have two radiobutton groups.
I think you should explain better what you need, also what you get from database, etc... is very difficult to figure out what you need with so few information.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
you are correct.there are many zones and many types of paying ways.
can you give me exmple how to solve.
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
No, I cannot because I have no idea what you are getting from your database and how you receive it in your JSP, but I can guess that the desired generated html should be something like this (with more beautiful styles):



Then how to build it depends on the data you have.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
no .
zone , type1 , type2 ,type3

i need to select zone and one of any type.
so how the radio button codes gone?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Can you really not extrapolate from what's above to get the appropriate collection of radio buttons?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: print database values with radio button