Results 1 to 2 of 2

Thread: Input tag name issues

  1. #1
    Join Date
    Jun 2005

    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
    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
    $_POST['check'] as $name => $value)
    // do whatever you want with $name and $value

    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

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