www.webdeveloper.com
Results 1 to 2 of 2

Thread: Input tag name issues

  1. #1
    Join Date
    Jun 2005
    Posts
    201

    Input tag name issues

    I have a pretty complex situation here. I have a form that has 100+ checkboxes that are all name differently. The value of the checkbox has to be a number because of a javascript script that adds up their checked values. I want a way to insert into the database the name of the field and not the actual value. Is there a way to get PHP to get the <input tag> names and spit them out to you? Also, how to do you loop through values submitted in a form? Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,923
    HTML Code:
    <input type="checkbox" name="check[name1]" value="1">1
    <input type="checkbox" name="check[name2]" value="2">2
    <input type="checkbox" name="check[name3]" value="3">3
    PHP Code:
    if(count($_POST['check']))  // at least one was checked
    {
       foreach(
    $_POST['check'] as $name => $value)
       {
          
    // do whatever you want with $name and $value
       
    }

    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles