Jesse, don't worry about having questions, they are welcome on this list.

As far as your question, yes, it can be done. If you create a form input labeled data[Person][name] it will be referenced in the next page like this:

$_POST['data']['Person']['name]

Some frameworks use this extensively, as it makes it easy to recursively go over data.

- Brian



Jesse Callaway wrote:
On Wed, Jan 28, 2009 at 12:30 AM, Michele Waldman <[email protected]> wrote:
Fernando hit is right on the head and Elijah's post was fun.  Why are we
still going here?

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Jesse Callaway
Sent: Wednesday, January 28, 2009 12:15 AM
To: NYPHP Talk
Subject: Re: [nyphp-talk] How to pass array when click on "submit" ?

On Tue, Jan 27, 2009 at 7:44 PM, Zakir Tariverdiev
<[email protected]> 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 <[email protected]> wrote:

From: chad qian <[email protected]>
Subject: [nyphp-talk] How to pass array when click on "submit" ?
To: [email protected]
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
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show_participation.php

--
realm3 web applications [realm3.com]
Information architecture, application development.
phone: (917) 512-3594
fax: (440) 744-3559
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show_participation.php

Reply via email to