All pastes #920306 Raw Edit

Miscellany

public html v1 · immutable
#920306 ·published 2008-02-27 10:13 UTC
rendered paste body
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>	<head>		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">		<title>Untitled Document</title>		<script type="text/javascript">			var selected = [];						function doSomething() { 				var last_index = getLastIndex();				alert(last_index);			}			function getLastIndex() { 				var el = document.getElementById('x');				for(i=0;i<el.length;i++) { 					if(el.options[i].selected && selected.indexOf(i,0,false)) { 						selected.push(i);						return i;					}				}								return -1;			}			// Array.indexOf( value, begin, strict ) - Return index of the first element that matches value			Array.prototype.indexOf = function(v,b,s) {				for(var i = +b || 0, l = this.length; i < l; i++ ) {					if( this[i]===v || s && this[i]==v ) { 						return i; 					}				}				return -1;			};		</script>	</head>	<body>		<select id="x" onchange="doSomething();" multiple="multiple" size="5">			<option value="1">One</option>			<option value="2">Two</option>			<option value="3">Three</option>			<option value="4">Four</option>			<option value="5">Five</option>		</select>	</body></html>