View Single Post
Old 01-11-2013, 11:32 PM   PM User | #6
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,529
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
An array would probably be easiest as then you'd only need a single statement to do the assignment.

Code:
<script type="text/javascript">

var vals = ["Off","Auto","Manual"];
function modetext() 
{
i = document.getElementById('datamem14').value;
if (i < 0 || i >= vals.length) i = 0;
document.getElementById('mode').value = vals[i]; 
}
</script>
Just add as many entries to the array as you need, the rest of the code will not need to be changed.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Users who have thanked felgall for this post:
JS Newbie (01-12-2013)