Can anyone please tell me how do I make this script run in IE 7? When I run this , nothing happens.
<html>
<head>
<script language="JavaScript">
function moveSelectedOption() {
// Fetch references to the <select> elements.
var origin = document.getElementById('origin_select');
var target = document.getElementById('target_select');
// Fetch the selected option and clone it.
var option = origin.options[origin.selectedIndex];
var copy = option.cloneNode(true);
// Add the clone to the target element.
target.add(copy, null);
}
</script>
</head>
<body>
<select id="origin_select" multiple>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select id="target_select" multiple>
<option value="C1">C1</option>
</select>
<button onclick="moveSelectedOption()">Add</button>
<!-- <input type="button" onClick="moveSelectedOption()" value="AddMeToo" /> this does not work either-->
</body>
</html>
Try
If you want to remove the option from the origin select element then you can use this
Demo without move
Demo with move
Edit
This line was causing the error.
See select.add