Passing a javascript variable to hidden input

Hi all,

I’m having some trouble with the this…

I have a PHP based calendar where the cells will change color depending on the number of clicks… this all works fine, but is pointless if I can’t send the outcome along in an email. I can do this with PHP but first need to get the values into a hidden field.

This is what I have:

<script type="text/javascript">	
	function countClicks (obj){
            if (!obj.count) {
                obj.count = 0;
            }
 
            obj.count++;
            if (obj.count > 4) {obj.count = 1};
 
            if(obj.count == 1){
                obj.style.color='#FFFFFF';
                obj.style.backgroundColor='#66CC33';
                obj.parentNode.style.backgroundColor='#66CC33';
				document.getElementById("availability").value='Available';
            }
           
            if (obj.count == 2){
                obj.style.color='#FFFFFF';
                obj.style.backgroundColor='#FF0000';
                obj.parentNode.style.backgroundColor='#FF0000';
				document.getElementById("availability").value='Not Available';
            }
           
            if (obj.count == 3){
                obj.style.color='#FFFFFF';
                obj.style.backgroundColor='#FFCC33';
                obj.parentNode.style.backgroundColor='#FFCC33';
				document.getElementById("availability").value='Working';
            }
			
			if (obj.count == 4){
                obj.style.color='#000000';
                obj.style.backgroundColor='#FFFFFF';
                obj.parentNode.style.backgroundColor='#FFFFFF';
				document.getElementById("availability").value='Not Set';
            }
        }
</script>

and…

echo "<input type=\\"hidden\\" name=\\"availability\\" id=\\"availability\\" value=\\"\\">";

All I’m trying to do is populate value with either ‘available’, ‘not available’, ‘working’ or ‘not set’…

however, it is worth noting that each cell may have a different value, e.g. 1 cell might be working while the other is not available… so i need to pass the values of all the cells.

Can anyone help me out here.

Many thanks,

Greens85

It’s in PHP, hope thats not a problem:

if($day_count == 1 || $day_count == 7){
		echo "<td id = \\"td1\\" align=\\"center\\" class=\\"weekends\\" bgcolor=\\"#EEEEEE\\">$day_num</td>";
	}else{
		//if the date has passed blank it out
		if($day_num < $day) {
			echo "<td id = \\"td1\\" align=\\"center\\" class=\\"olddays\\" bgcolor=\\"#EEEEEE\\">$day_num</td>";
		}else{
			echo "<td id = \\"td1\\" align=\\"center\\" bgcolor=\\"#FFFFFF\\"><a href=\\"#\\" onclick = countClicks(this)>$day_num</a></td>";
			echo "<input type=\\"hidden\\" name=\\"availability\\" id=\\"availability\\" value=\\"\\">";
		}
	}

The echo that shows the hidden field is the one i’m trying to sort.

I’m happy to provide the whole script as an attachment if it helps you at all.

Give us the few lines of cells generating code. So i can give you better idea of how to pass each cell availability.