how to store checkbox status in database?
843838Apr 23 2007 — edited Apr 25 2007Hi 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 .