Hi guys,

i'm having a little trouble with a script. I'm not that good at javascripting/jquery etc., so i'm gonna need your help.

I'm building a website where registered users can place messages in different categories. What i'm trying to do is to give a user after registration on my site the opportunity to choose how many categories and which categories they can post in. So it looks a bit like this:


* Number of categories: [input field with standard value set as 3 with id='cat'] (+) (-)

*Choose your categories ( [] = checkbox with name='ckb' and id=cat name(cat1,cat2, etc))
[] cat 1 [] cat 4
[] cat 2 [] cat 5
[] cat 3 [] cat 6

Register.js (included in index.php)-----------------

window['aant'] = document.getElementById('cat').value //Global variable

function add(name) {
	if (name == 'cat') {
	if (document.getElementById(name).value < 12) {
		var value = parseInt(document.getElementById(name).value);
		var newvalue;
		newvalue = value + 1;
		document.getElementById(name).value = newvalue;
		window['aant'] = parseInt(newvalue);

function checkboxlimit(checkgroup, limit){
	var checkgroup=checkgroup
	var limit=window['aant']
	for (var i=0; i<checkgroup.length; i++){
		var checkedcount=0
		for (var i=0; i<checkgroup.length; i++)
			checkedcount+=(checkgroup[i].checked)? 1 : 0
		if (checkedcount>limit){
			alert("You can only select a maximum of "+limit+" checkboxes")
So the global variable window['aant'] is set to the value that the inputfield of number of cats standard has (but it doesn't work, that value doesn't get assigned to that global variable). If you click the + sign after 'number of categories', the global variable should get a +1, so that the limit on the checkboxes get raised by one too.

But i can't get it to work. The getelementbyid doesn't work in the first place with the global variable. But even if i give it a standard number, for instance 3, then the limit on checkboxes doesn't get changed, it stays on 3. It has to be a getelementbyid because the number isn't always 3, it can be a different value if you choose another package in a earlier step in the registration process.

Maybe the problem is that the limit on checkboxes can't get changed without ajax or something. I've tried to implement jquery, but i really don't know much about it. Can anybody give me some advice?