Thanks. That works indeed, but my approach is a little different, so I do not yet see how I can do it the way you describe.
My approach is as follows:
1.) create object containing checkboxes (and others)
the object has the following variables
$name1 (=value of checkbox 1 or 0)
$name1inputtype (=checkbox)
$name2 (=value of checkbox 1 or 0)
$name2inputtype (=checkbox)
etc
the initial values are set in the constructor
2) for allnames (i.e. name1 name2 etc) {
display_object_characteristic($object,$namek,$namekinputtype,$line);
echo $line;
function display_object_characteristic(&$object,&$namek,&$namekinputtype,&$line)
{
if ($$namek) {
$object->set_option($namek,$$namek); // sets this->namek=$$namek
}
else // can actually be done after next statement as well
{
$checkedval=$object->get_option($namek); // gets this->namek
$object->set_option($namek, $checkedval); // sets this->namek=$$namek
}
$checkedval=$object->get_option($namek);
$value="1";
$namekinputtype($namek,$value,$checkedval); // equivalent to checkbox($namek,$value,$checkedval,$line);
}
checkbox($namek,$value,$checkedval,&$line)
{
line="<name=\"$namek\" value=\"$value\ "
line.="OnClick=\this.form.submit\ " //can't remind the exact code but this works (Javascript)
if ($checkedval==1)
{
line.=" checked";
}
line.=">";
}
I hope this pseudo code is clear, if not let me know, then I can give you my exact (stripped) code. My basic problem is the 'hard coded checked' by doing it this way. Can I make it dynamic, without losing the 2 (sub)functions. I wat to keep them because I want to do more or less the same with other form input types.