Posted by GD on 04/01/07 16:18
It works great. Thanks!
GD
"Rami Elomaa" <rami.elomaa@gmail.com> wrote in message
news:eunlpr$jke$1@nyytiset.pp.htv.fi...
> GD kirjoitti:
>> Hi,
>>
>> I am trying to get values from table cells and textboxes that have same
>> component names in a table after posting to the same page. Javascript is
>> able to get the component values while the components have same names.
>> For
>> example:
>>
>> for (var i=0; i < document.FormTest.txtTest.length; i++)
>> {
>> alert(document.FormTest.txtTest[i].value);
>> }
>>
>> How to do it using PHP? The following is the test code:
>> -------------------------------------------------------
>> <html>
>> <head> <title>Test</title></head>
>>
>> //try to get values after posting
>> <?php
>> $textboxValue = $_POST['txtTest'];
>> echo $textboxValue;
>> ?>
>>
>> <body bgcolor="#ebeaff" >
>> <form name="FormTest" id="FormTest" action="test.php" method="post" >
>>
>> <?php
>> echo "<table>";
>> for ($counter = 0; $counter <= 3; $counter++)
>> {
>> echo "<tr><td><input type='text' name='txtTest'></td><td>cell
>> value</td></tr>";
>> }
>> echo "</table>";
>> ?>
>>
>> </form>
>> </html>
>> -----------------------------------------------
>>
>
> Add [] to the field names so that php makes an array of them:
> <input type='text' name='txtTest[]'>
>
> Then you can access them thru $_POST['txtTest'][0] etc...
>
> --
> Rami.Elomaa@gmail.com
> "Olemme apinoiden planeetalla."
Navigation:
[Reply to this message]
|