You are here: Re: - setting checkboxes « HTML « IT news, forums, messages
Re: - setting checkboxes

Posted by Jonathan N. Little on 08/07/06 23:24

Sonnich wrote:

>
> <html>
> <form method=post name='myform' action='sjjtest.php'><!-- same file -->
> <table>
> <?
> $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]]
> ."</td></tr>";
> }
> ?>
> <tr><td><input class="box" name="apply_selection" type="submit" value="
> Apply selection "></td></tr>
> </table>
> </form>
> </html>
>
> Try it and you will see
>

Not sure what you are trying to accomplish here but in PHP block
statements need to be surrounded by braces {} therefore it think your
PHP part should be:


<?
$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]] == "") )
{ //needed open brace
echo " checked";
} //closing brace

echo ">". isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]
.."</td></tr>";
}
?>


But again not sure what your aim is here....

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация