TVGuide-NL

 view release on metacpan or  search on metacpan

examples/prefs.js  view on Meta::CPAN

	/* loop over all <options>, start at 2nd */
	var i;
	for (i=1; i<target.options.length; i++) 
	{
		/* if it's selected */
		if (target.options[i].selected == true)
		{
			/* move it upwards */
			var saved = target.options[i-1];
			target.options[i-1] = null;

			if (i==target.options.length)
				appendOption( saved, target );
			else
				insertOption ( saved, target, i );
		} 
	}
	
	return true;
}

function moveDown()
{
	var target = document.getElementById('select');

	/* return if list is empty */
	if (target.options.length == 0)
		return true;

	/* don't do anything if the bottommost option is selected */
	if (target.options[target.options.length - 1].selected == true)
		return true;

	/* inverse loop over all <options>, start at last but one */
	for (i=target.options.length-2; i>=0; i--) 
	{
		/* if it's selected */
		if (target.options[i].selected == true)
		{
			/* move it downwards */
			saved = target.options[i+1];
			target.options[i+1] = null;
			target.add( saved, target.options[i] );
			
		}
	}
	
	return true;
}

function submitForm()
{
	var source  = document.getElementById('select');

	var postvar = '';
	/* loop over all <options> */
	for (i=0; i<source.options.length; i++) 
	{
		postvar += 's' + i + '=' + source.options[i].value + ';';
	}
	document.location = 'prefs.cgi?' + postvar + 'save=yes';
}



( run in 0.514 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )