Getting a checkbox checked from database.

Results 1 to 3 of 3

Thread: Getting a checkbox checked from database.

  1. #1
    Join Date
    Dec 1969
    Posts
    119

    Default Getting a checkbox checked from database.

    I am filling up a field in database through check box. When I read that field into HTML form, it doesnot give me in response in the form of checked Checkbox.<BR>I want that if the field stores checked value of checkbox, it should display a checked checked box. How can this be done? Is there a way in javascript either?<BR>Thanks

  2. #2
    Join Date
    Dec 1969
    Posts
    32

    Default RE: Getting a checkbox checked from database.

    Hi Arvind,<BR><BR>Here it goes.I assume u are using MS-Access db.<BR>&#060;%<BR>varchk=EMPTY<BR>&#039check if the database check box is checked.<BR>if rs("dbchkbox")="yes" then <BR>&#039set a variable to value "checked", if true<BR>varchk="checked"<BR>end if<BR>%&#062;<BR>&#060;!-- If varchk has the value,"checked" then check box will be checked,not otherwise--&#062;<BR>&#060;input type="checkbox" name="chkbox_name" &#060;%=varchk%&#062;&#062;<BR><BR>Hope this helps!!!

  3. #3
    Join Date
    Dec 1969
    Posts
    22

    Default RE: Getting a checkbox checked from database.

    Here iam giving the code fro check box group:<BR>You apply the same for the single check box by removing the loop<BR>for(var i=0;i&#060;document.form1.checkbox.length;i++)<BR> {<BR>if (document.form1.checkbox[i].value=="&#060;%=rs("value")%&#062;")<BR>document. form1.checkbox.[i].checked=true<BR>}<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •