Re: form and arrays[]
It's possible to have form variables submitted as an array. In your
HTML, just add [] after the variable name (like a PHP array). So, to
draw the form you might have something like this:
for($i = 0; $i < 12; $i++) { ?>
<input type="text" name="description[<?=$i?>]"/>
<input type="text" name="amount[<?=$i?>]"/>
<? } ?>
Of course you'll need to adjust the <?=$i if you don't have short open
tags enabled.
Once the form has been submitted, $_POST['description'] will be an
array rather than a single value. So, you can reference
$_POST['description'][2] if you wanted.
To turn these variables into a string, you could do something like
this:
$str = '';
for($i = 0; $i < 12; $i++) {
$str .= $_POST['description'][$i] . "," . $_POST['description'][$i]
.. "\n";
}
.
Relevant Pages
- Re: nested conditional that can identify parent page?
... and specify the files in the array including ... try to make as little php and html mix as possible, have a template ... (alt.php) - Re: Proper coding? (JS newbie)
... Document content looks like HTML 4.01 Transitional ... also in the FAQ. ... array; one fewer thing to change if another button is added. ... Use W3C standard ... (microsoft.public.scripting.jscript) - Re: Can a default value be specified for a drop-down list?
... Theo wrote: ... > HTML requires the particular menu choice to be listed as 'selected'. ... add php code to each choice. ... > The line using a php array is ... (comp.lang.php) - Re: create array from members of an array of objects
... $listis an array of MyElement objects. ... I'm working together with another person who is not a programmer: he's an HTML author and I need to make the code structure as essential as possible. ... $aValues is an array containing the key-value couples to be displayed in the select. ... This way, my friend, who does not know php, is able to move the select anywhere on the page by simply moving the php code line, and I do not risk to have my code corrupted by a mistake by my friend. ... (comp.lang.php) - Re: new to AJAX -- can you do this?
... I added interface to HTML interface to insert info into db; info gets inserted in to db in a servlet then servlet redirects back to HTML interface, where if user types something from array it gets printed about two lines down.. ... have two 'main' functions functions..) one for printing sel Obj w/info from db when pg loads and one for printing text on pg according to what user selects in sel obj.. ... each function calls a diff JSP (don't know yet how to do this with both functions calling same JSP, ... (comp.lang.javascript) |
|