|
Posted by Rik on 08/08/06 13:03
Sonnich wrote:
> Rik wrote:
>> Sonnich wrote:
>>> <?
>>> $part1[]="a";
>>> $part1[]="b";
>>> $part1[]="c";
>>> for($i=0; $i<count($part1); $i++)
>>> {
>>> echo "<td><input name=\"".$part1[$i]."\" type=\"checkbox\"
>>> value=\"true\"";
>>> if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] == "") )
>>> echo " checked";
>>> echo ">". isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]
>> Euhm, what it this last bit
>> 'isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]' actually supposed to do?
>> It will either print '1-true' or ''(nothing)?
>
> That was meant as debugging :-)
>
>>> ."</td></tr>";
>>> }
>>
>> You've got a submit button, it's name is in the POST array, so it should be
>> present if the form is posted. Before posting, everything should be checked.
>> After the posting only the previously left checked values should be checked,
>> the rest unchecked. Is that how it should work? in that case:
>
> Almost.
> In case of any new items, they should be checked too.
>
> There are other options, which might change sql query and by that the
> array, so we have new items. They should be selected by default when
> they appear.
> Otherwise I found this useful.
>
> I'll have to read a bit more about this subjet for PHP.
Well, if we have to check wether the fields existed on the last
page-load, there are several options:
- store the request time, and the date fields get added. This is
somewhat bulky.
- store the available fields in a session, and on reload compare the
session variable with the then available fields.
- add an input type=hidden for every field, containing the name, and on
submit check wether an available name is in the POST array or not.
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|