#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    3
    Rep Power
    0

    Checkbox check javascript/php


    Hello!
    I have a form where I want to check only one checkbox. In javascript this is easy but the problem is that I use MySQL and I have a database that spits out the checkboxes. Which means I don't know how many checkboxes there are.
    I.e. I have table with 5 elements and this would generate 5 checkboxes. Now when I check one box it should be checked and the others, if there are any, should be unchecked. Next time though it might be more or less checkboxes. Please help!

    /Birger_Kung
  2. #2
  3. // no comment
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2001
    Posts
    1,645
    Rep Power
    39
    why dont you just use radio boxes for your options. much simpler if you only want one option checked.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    3
    Rep Power
    0
    I know, but they aren't as goodlooking as checkboxes. Any other ideas?
  6. #4
  7. // no comment
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2001
    Posts
    1,645
    Rep Power
    39
    i believe you can do this in javascript. if you already have a javascript available for premade chkboxes. why dont you just have php generate a javascript for this depending on the number of results you have.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    3
    Rep Power
    0
    But I still don't know how many or the names on the checkboxes. How do I referr to somethimng that don't have a name?
  10. #6
  11. // no comment
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2001
    Posts
    1,645
    Rep Power
    39
    you generate the javascript on runtime when you fetch your info from the database.

    place the names of your checkboxes in an array, then after you've created all the checkboxes, you can now generate the javascript for this depending on the number of options you have.

IMN logo majestic logo threadwatch logo seochat tools logo