getting value of checkbox.

i have created a servlet on which there are some check box values and on other servlet i want to retrieve those values that too from the database(JDBC:ORACLE).

help

[177 byte] By [performersa] at [2007-11-27 11:39:23]
# 1

I don't know much about servlets, but you can retrieve the value of a JCheckBox by calling isSelected().

But what are you trying to do? Retrieve the value from the JCheckBox's state or from the DB?

java_knighta at 2007-7-29 17:25:46 > top of Java-index,Java Essentials,Java Programming...
# 2

i am making a mini website in which a html page is generated through a servlet n it contains some checkbox values, now what i am trying to do is that, i just want to take the checked values from that html page to the action of the form.

please help me out with this.

performersa at 2007-7-29 17:25:46 > top of Java-index,Java Essentials,Java Programming...
# 3

> i just want to take the checked values from that html

> page to the action of the form.

I Did something similar a while ago, though I Dont understand something, you want the values taken from the Html and depending on them the behavior of yor form will change?

Could you give me more info or some code to look at? It's easier to help with some actual reference instead of just words.

Thanks.

efainsoda at 2007-7-29 17:25:46 > top of Java-index,Java Essentials,Java Programming...
# 4

> i just want to take the checked values from that html

> page to the action of the form.

Have a look at the getValues() or getParameterMap() methods in HttpServletRequest. An entry-level servlet tutorial may be of some use as well.

~

yawmarka at 2007-7-29 17:25:46 > top of Java-index,Java Essentials,Java Programming...
# 5

Get the value using js and assign it to a hidden field. From the hidden you can take the value in the server side. Then use, StringTokenizer to read each token.

function subForm()

{

var j = 0;

var check_values = new Array();

var the_form = window.document.forms[0];

var commaVal;

for(var i=0; i<the_form.length; i++)

{

var temp = the_form.elements[i].type;

if((temp == "check") && (the_form.elements[i].checked)) {

check_values[j] = the_form.elements[i].value;

j++;

}

}

for(var k=0; k><check_values.length; k++)

{

commaVal = commaVal + check_values[k] + ","; //get as comman delimited string

}

document.getElementById("hiddenfield").value = commaVal; //assign to hidden

}

>

skp71a at 2007-7-29 17:25:46 > top of Java-index,Java Essentials,Java Programming...