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

    Join Date
    Jun 2000
    Posts
    20
    Rep Power
    0
    I'm creating a page that includes check boxes that are dynamically pulled from a MySQL database. I have gotten it to correctly pull up the boxes and name them, but when I make a change and submit, all of the values that were checked are set to 0 instead of 1.

    This should print out a checkbox, checked if it is supposed to be, and take an argument to be passed when the user chooses to update the page.
    When I submit my form, all of the checkboxes pass a value of zero even when they are checked.
    Can you tell me if there is an error in this statement?


    print "<td valign='top'>";
    print "<input type=checkbox name=checkbox_$cat_name value='checked' $checked[$j]></td>";
    print ${"checkbox_".$field_name}." !!!";
    print "<td valign='top'>$list_cat_name</td>";


    $checked[$j] - contains the value 'checked' or nothing set (correctly) earlier in the file
    the checkboxes are named checkbox_(fieldname) [ex: checkbox_food]

    The value 'checked' is passed to another file that updates the db

  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    print "<td valign='top'>";
    print "<input type=checkbox name=checkbox_$cat_name value='checked' $checked[$j]></td>";
    print ${"checkbox_".$field_name}." !!!";
    print "<td valign='top'>$list_cat_name</td>";


    tigg,

    i think you should put value="1" in check box.

    ie,


    echo "<input type="checkbox" name="checkbox_".$cat."_name" value="1" $checked[$j]></td>";


    i hope that will solve your problem..




    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    20
    Rep Power
    0
    That didn't work.
    I still get nothing but "!!!"s from the statement, so I believe that the problem has to be in the <input> statement
    In 'values="foo"' foo is the value that is returned when the box is checked.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    7
    Rep Power
    0
    I am doing a similar thing in one of my scripts. Here is what I am doing:

    <input type="checkbox" value="show_email" name="show_email" <? if ($show_email == "show_email") echo "checked"; ?>>

    This works like a charm! I'm just checking to see if @show_email has already been set, and if so, just output CHECKED, which turns on the checkbox. Hope this helps for you.

    Alex Dossey

Similar Threads

  1. Mysql problem.
    By Nik in forum MySQL Help
    Replies: 54
    Last Post: December 21st, 2006, 06:02 PM
  2. MySQL to MS SQL 2000
    By diskord in forum MySQL Help
    Replies: 0
    Last Post: February 6th, 2004, 07:00 PM
  3. Upgrade from access to mysql
    By karib1 in forum ASP Programming
    Replies: 7
    Last Post: December 16th, 2003, 12:35 PM
  4. Upgrade from access to mysql
    By karib1 in forum MySQL Help
    Replies: 1
    Last Post: December 16th, 2003, 12:27 AM

IMN logo majestic logo threadwatch logo seochat tools logo