Question: I have a type of grocery list where I want to able to add items from different stores.

Currently I have a form where I post the article number and quantity and then press submit to add the item to the grocery list (the table below).

```
<form action="<?php echo $current_file.$id; ?>" method="POST">

    Store:  <select>
                    <option value="gross1">Store 1</option>
                    <option value="gross2">Store 2</option>
                    <option value="gross3">Store 3</option>
            </select>

    Art no: <input type="text" size="15" name="number"  /> 

    Quantity: <input type="text" size="3" name="q" />

    <input type="submit" value="Add item" />

</form>

<table>
    <tr>
        <th>
            Art no
        </th>
        <th>
            Article name
        </th>
        <th>
            Price
        </th>
        <th>
            Quantity
        </th>
        <th>
            Total
        </th>
    </tr>

```

The stores item lists are stored in mysql tables so I want to choose the store (or the table if you so will) via a drop down select list. But the problem is, if the store I'm choosing items from isn't store 1, its going to pretty frustrating to select the store over and over again after every time I press submit.

I don't think I can use a script that uses some kind of GET variable to specify the selected store, because I already use GET to specify the selected grocery list. Is there another way to get the site to remember the selected store after a page refresh?

Thanks in advance!

Answer: 
I'd suggest:

```
var colors = ["green", "red", "black"];

function setColor(el) {
    el.colorIdx = el.colorIdx || 0;
    el.style.color = colors[el.colorIdx++ % colors.length];
    document.getElementById('box1').checked = el.style.color == 'green';
    document.getElementById('box2').checked = el.style.color == 'red';
}

```

[JS Fiddle demo](http://jsfiddle.net/davidThomas/dkY5e/).
Do it like this:

```
var index = el.colorIdx++ % colors.length;
if( index == 2 ) //2 is the index of color black
{
  document.getElementById("box1").checked = false; 
  document.getElementById("box2").checked = false; 
}
else if( index == 0 )
{
   document.getElementById("box1").checked = true;     
}
else
{
   document.getElementById("box2").checked = true;       
}

```