The website I am working on now has a list where the user should click on a
checkbox and then have then could check the items the user want and this
should be used later.

When I started doing this, I created the the checkbox like this: <input
type="checkbox" name="favorite" value="${offers/idoffer}"
OnCheckedChanged="submit();" onclick="if(this.checked)

Then I was thinking that I should place this in a array that I so place in a
session variable, so when the page here refresh, the item is still checked
and I also have access to the favorites later in the process.

This is the code in the php file that create the array and that I place in
the session vaiable:
isset($_SESSION['fav']) ? $_SESSION['fav'] : $_SESSION['fav'] = null;
if(isset($_GET['submit']) && $_GET['submit'] == 'fav') {
    if(count($_SESSION['fav']) < 5) {
        $_SESSION['fav'][] = array("idoffer" => $_POST['favorite'],
"checked" => true);
    $tmp = Array();
    foreach($_SESSION['fav'] as $f) {
        $tmp[$f['idoffer']][] = $f['checked'];
    $_SESSION['fav'] = $tmp;

Now I was thinking to use tal:attributes="checked x" something like that to
be sure that it the item is checked after the checking submit the form.

Is this totally wrong way to get my idea to work?

Hope anyone can help me with this one.


PHPTAL mailing list

Reply via email to