Results 1 to 4 of 4
  1. #1

    Passing an array via a Form?

    Is it possible to pass an array via a form without setting hidden variables? If so, how?
    "It's hard to dance if you just lost your wallet. Whoa! Where's my wallet? But, hey this song is funky." - Mitch Hedberg

  2. #2
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    3,100
    language, example ..?

    In php you can do
    <form method="get">
    <input name="somevar[]" value="1">
    <input name="somevar[]" value="2">

    And then you will get an array:
    print_r($_GET['somvar']) ;

    Array (
    0='1',
    1=>'2'
    )
    or something close to it

  3. #3
    PHP Code:
    <form method="post">
    <input type="checkbox" checked="checked" name="foo[0]">
    <input type="checkbox" checked="checked" name="foo[1]">
    <input type="checkbox" checked="checked" name="foo[2]">
    <input type="submit">
    </form>
    <? if (isset($_POST['foo'])) var_dump($_POST['foo']); ?>

  4. #4
    Thanks guys, I'll try that tonight. Looks like it should work with what I have in mind.
    "It's hard to dance if you just lost your wallet. Whoa! Where's my wallet? But, hey this song is funky." - Mitch Hedberg

Posting Permissions

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