• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in getting the state of checkbox  RSS feed

Polireddy Vanukuri
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSP file which connects to DB and dispaly in aTable format by putting a checkbox as a first column of every row dispay. I am giving a name to every checkbox but its not a static name , its a name given dynamically by incrementing a varible in the process of looping(while)The checkbox names are

As the browser won't send the checkbox stauts which is not checked(for that it is throw NullPointerException,i verified), I m using hidden filelds. i m giving the name to them as chbSetState0,chbSetState1,chbSetState2,.... i m giving Initial values for these are as 0(zeroes).

I m going to set corresponding hidden value to 1,when the user clicks a checkbox. For that i m calling the function .. setState().
To set a hidden value to 1, i have to get the index name of the checkbox
that the user checked,that means i have to append that index value(index_chbSelected) to the hidden field name in this way....
// getting the index of check box clicked
var index_chbSelected=window.event.srcElement.name.charAt(4);

// setting the corresponding hidden value

But its an error javascript.

The logic i written is to know the other page(jsp page will get the hidden field values.If a hidden field value is 1,it treats check box selected)get checkbox state in the current jsp page.

I tried so much to get solution for this.

If any one understood my problem, pls help me to solve this problem.
[ July 29, 2006: Message edited by: Bear Bibeault ]
Ben Souther
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript issues are discussed in our HTML/Javascript forum but before sending this thread there, let me suggest another approach.

If you're creating the names with an incrementing number, you should be able to read them the same way. Just be sure to create a hidden form field that contains the number of checkboxes (cbCount).

(Remember: getParameter returns null if you request a param that wasn't sent)

Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!