Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'html checkboxes'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. assuming I create this array: $vegetables=array('corn','squash','beans','carrots','peas','kale'); The following check boxes work fine in my form. <div class="checkbox"> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[0]?>"> <?php echo $vegetables[0]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[1]?>"> <?php echo $vegetables[1]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[2]?>"> <?php echo $vegetables[2]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[3]?>"> <?php echo $vegetables[3]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[4]?>"> <?php echo $vegetables[4]?></label> <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[5]?>"> <?php echo $vegetables[5]?></label> </div> But I've been trying to go one step further so if I add another vegetable to $vegetables[] , I won't have to add another line of code in the check boxes. For example, if I add "spinach", I won't also have to add the line: <label><input type="checkbox" name="vegetables[]" value="<?php echo $vegetables[6]?>"> <?php echo $vegetables[6]?></label> I tried forever by using something along the lines of: foreach ($vegetables as $key =>$value) // mixing html and PHP here to create each of the 6 "<label> </label>" lines of code. } That way, all I have to do is add a vegetable to $vegetables and not change the html I thought I had it at one point but I wasn't able to check more than one of the boxes at a time. thanks for any comments chop
×
×
  • Create New...