Drawing checkboxes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hello,

I am having a hard time figuring this one out, maybe someone here (with
fresh eyes) can offer a suggestion?

Here is the function...

// Draw Checkbox Menu
function draw_checkbox_menu($name, $values, $default = false, $parameters =
false) {
    
    

    for ($i=0; $i<sizeof($values); $i++) {
        $field .= '<input type="checkbox" name="'.$name.'" value="' .
$values[$i]['id'] . '"';
        if(strstr($default, $values[$i]['id'])) {
            $field .= ' CHECKED';
        }
        $field .= '> ' . $values[$i]['text'] . '<br>
        ';
    }

    return $field;
}

This function is passed the name of the checkbox list($name), the values
that are available($values = array) along with the ones that should be
checked ($default). Parameters too , but not important.


The problem is this. The Values are formatted like this...

value1|value2|value3...etc...

I use the strstr() function to check against the $default so I can check it
if so.

Well it works great..BUT, lets say the product has a category of "Coffee
Pots", but the one of the values available is "Coffee".

In this case both "Coffee" AND "Coffee Pots" get checked when only "Coffee
Pots" should.

What can I do to this function eliminate this?

Thanks




+--------------------------------------------+
Mike Yrabedra 
Mac@xxxxxxxx 
Your Mac Intelligence Resource
+--------------------------------------------+
W: http://www.macagent.com/
E: agenty@xxxxxxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux