Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to store checkbox status in database?

843838Apr 23 2007 — edited Apr 25 2007
Hi all,
I am developing an application using struts. I hv a problem with checkboxes.. I want to store 1 if checked and 0 if not. i.e. if I have 5 checkboxes and is I check 1st and 3rd checkboxes then I should have it in the form 10100.. and I want to store it in database.. I m using MySQL as backend.

I used a javascript code in my jsp page to check status of checkboxes.. but I dont know how to return this string to ActionForm..

function checkStatus()
{
wday=document.forms[0].wday
weektxt=""
for (i=0;i< wday.length;++i)
{
if (wday.checked)
{
weektxt=weektxt + 1
}
else
{
weektxt=weektxt + 0
}
}

mday=document.forms[0].mday
monthtxt=""
for (i=0;i< mday.length;++i)
{
if (mday[i].checked)
{
monthtxt=monthtxt+ 1
}
else
{
monthtxt=monthtxt + 0
}
}
return weektxt;
return monthtxt;
}

can u plz help me? or if there is some another way plz suggest.
Thanks in advance.

Monali .
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 23 2007
Added on Apr 23 2007
12 comments
535 views