NYCPHP Meetup

NYPHP.org

[nycphp-talk] How to pass array when click on "submit" ?

Jesse Callaway bonsaime at gmail.com
Thu Jan 29 00:34:20 EST 2009


On Wed, Jan 28, 2009 at 12:30 AM, Michele Waldman <mmwaldman at nyc.rr.com> wrote:
> Fernando hit is right on the head and Elijah's post was fun.  Why are we
> still going here?
>
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
> Behalf Of Jesse Callaway
> Sent: Wednesday, January 28, 2009 12:15 AM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] How to pass array when click on "submit" ?
>
> On Tue, Jan 27, 2009 at 7:44 PM, Zakir Tariverdiev
> <zakir_tariverdiev at yahoo.com> wrote:
>> OnClick=AddRow()"... are you trying to send a JavaScript array to the
>> server?
>> This is not really a PHP issue. But check out the following link,
>>
> http://www.coderanch.com/t/120794/HTML-JavaScript/sending-javascript-array-s
> erver
>> it might help.
>>
>> Also, note that your City and State <input tags> are enclosed inside
>> <label>, I don't think that was intentional on your part.
>>
>>
>> --- On Mon, 1/26/09, chad qian <nynj.tech at hotmail.com> wrote:
>>
>> From: chad qian <nynj.tech at hotmail.com>
>> Subject: [nycphp-talk] How to pass array when click on "submit" ?
>> To: talk at lists.nyphp.org
>> Date: Monday, January 26, 2009, 10:54 PM
>>
>> In "tbody",I can add or remove more
> "name[]","position[]","city[]","state[]"
>> and "zip[]" through "add" or "remove" buttons.
>> On "create.php" page, I expect to show all like:
>> 1.
>> name
>> position
>> city
>> state
>> zip
>> 2.
>> name
>> position
>> city
>> state
>> zip
>> 3.
>> name
>> position
>> city
>> state
>> zip
>> ----------
>> --------
>> --------
>>
>> How to program php script to pass all these above
>> information?"name","position","city","state" and "zip" are all array.
>>
>> Thanks!
>>
>> chad
>>
>> <form name="form1" method="post" action="create2.php">
>> <tr>
>> <td><strong>Step2: Board of directors:(Must have at least
> one)</strong></td>
>> <td>&nbsp;</td>
>> </tr>
>> <tbody id="dynamic_table_body">
>> <tr>
>> <td><label>Name:</label></td>
>> <td> <input type="text" name="bn[]" id="bn" /></td>
>> </tr>
>> <tr>
>> <td>Position:</td>
>> <td><label>
>> <select name="select[]" id="select">
>> <option value="president" selected>president</option>
>> <option value="vice president">vice president</option>
>> <option value="secretary">secretary</option>
>> <option value="others">others</option>
>> </select>
>> </label></td>
>> </tr>
>> <tr>
>> <td>City:</td>
>> <td><label>
>> <input type="text" name="city[]" id="city" />
>> </label></td>
>> </tr>
>> <tr>
>> <td>State:</td>
>> <td><label>
>> <input type="text" name="state[]" id="city" />
>> </label></td>
>> </tr>
>> <tr>
>> <td>Zip:</td>
>> <td><label>
>> <input type="text" name="zip[]" id="textfield3" />
>> </label></td>
>> </tr>
>> <tr>
>> <td colspan="2"><button type="button" onClick="AddRow ();">Add
>> </button></td>
>> </tr>
>> </form>
>>
>> ________________________________
>> Windows LiveT Hotmail(R):.more than just e-mail. Check it out.
>>
>> _______________________________________________
>> New York PHP User Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/show_participation.php
>>
>> _______________________________________________
>> New York PHP User Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/show_participation.php
>>
>
>
> The name of a form element affects the data type? Doesn't some sort of
> eval or ${} magic have to happen here? This is a little funky playing
> around with bareword interpretation.
> Is there some switch in the global configuration which turns this kind
> of insanity off? I want my hash keys to be plain old strings, whether
> they have square brackets in them or not.
>
> Referring to Elijah's post, er email... I would expect that
>
>
> <input name="data[test][]" value="index 0" />
>
>  would yield a normal 1-dimensional array with an unfortunately named key
>
> $_POST['data[test][]'] == "index 0"
>
> -jesse
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>

I was just kind of caught off guard, not trying to derail the
discussion. I had no idea that this could be done. Is it really true?

-jesse



More information about the talk mailing list