Forum Moderators: open

Message Too Old, No Replies

Form Submittal Challenge

How can I reduce number of variables?

         

treeline

1:09 am on Feb 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to design a form that selects multiple locations. For usability reasons I'm using three seperate SELECT boxes to choose 3 locations. This gives me 3 variables passed back.

  • place=ohio&place2=texas&place3=iowa

    My script is designed to take one variable, with commas separating places:

  • place=ohio,texas,iowa

    How can I use multiple SELECT boxes and end up with this single variable & commas between locations? Is there another approach I should look at?

    Thanks for your help! :)

  • dcrombie

    11:13 am on Feb 4, 2005 (gmt 0)



    There's a number of ways you could do this using JavaScript - but just as many reasons not to.

    IMHO best practice would be to name all three SELECT boxes "place[]". Then, when the form is submitted, you will have a single variable, $_POST["place"], which is an array of the values.

    ;)