Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<html>
<head>
<script type="text/javascript">
var maxAllowedItems = 8;
function updateInitialCount(selObj) {
var opts = selObj.options;
var count = 0;
for (var loop=0; loop<opts.length; loop++) {
if (opts[loop].selected) {
count++;
if (count > maxAllowedItems) opts[loop].selected = false;
}
}
return(count);
}
function copyOptions() {
var sel1 = document.getElementById('sel01');
var sel2 = document.getElementById('sel02');
var selectedCount = updateInitialCount(sel1); // Just in case onchange hasn't fired
sel2.options.length = 0;
if (selectedCount) {
var opts = sel1.options;
for (var loop=0; loop<opts.length; loop++) {
if (opts[loop].selected) {
addOption(sel2, opts[loop].text, opts[loop].value);
}
}
} else {
addOption(sel2, 'Please select some options from the previous box!', '');
}
}
function addOption(selObj, value, text) {
// copy options from array of [value, pair] arrays to select box
// IE doesn't work if you use the DOM-standard method, however...
if (typeof(window.clientInformation) != 'undefined') {
// IE doesn't take the second "before" parameter...
selObj.add(new Option(value, text));
} else {
selObj.add(new Option(value, text), null);
}
}
</script>
</head>
<body>
<form>
<select id="sel01" multiple="multiple" onchange="updateInitialCount(this);">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
<option value="6">Option 6</option>
<option value="7">Option 7</option>
<option value="8">Option 8</option>
<option value="9">Option 9</option>
<option value="10">Option 10</option>
</select>
<br />
<input type="button" onclick="copyOptions();" value="Copy selected options" />
<br />
<select id="sel02">
<option value="">Please select some options from the previous box!</option>
</select>
</form>
</body>
</html>