All pastes #920318 Raw Edit

Anonymous

public html v1 · immutable
#920318 ·published 2008-02-27 10:22 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++) { 					selected_index = selected.indexOf(i,0,true);					if(selected_index > -1) { 						if(el.options[i].selected == false) { 							selected.splice(selected_index, 1);						}					} else if(el.options[i].selected && selected_index == -1) { 						selected.push(i);						return i;					}				}				if(selected.length > 0) { 					return selected[selected.length-1];				}				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>