UPDATE: [21 Jan 2006] Changed method of returning values from the child popup window to call an update function in the parent page. Direct access to the field from the child did not work in Gecko engine browsers.
<!--THIS PAGE-->
<!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=UTF-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005-2010 Roderick Divilbiss">
<title>Select All In List</title>
<script language="javascript" type="text/javascript">
<!--
var childPopup = null;
function openPopup() {
// If the child popup is open, close it.
if (childPopup != null) {
if (childPopup.closed == false)
childPopup.close()
}
// open the child popup.
childPopup = window.open('get-Popup-List-Values.htm','child');
// return the window handle.
return childPopup;
}
function doUpdate(vals) {
document.getElementById('cpValues').value=vals;
}
//-->
</script>
</head>
</head>
<body>
<input type="text" id="cpValues" name="cpValues" size="50">
<input type="button" value="Open Popup" onclick="openPopup();">
</body>
</html>
<!-- THE CHILD POPUP NAMED "pop_up_list.htm" -->
<!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=UTF-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005-2010 Roderick Divilbiss">
<script language="javascript" type="text/javascript">
<!--
function selectAllList() {
// get the options collection of the list box
var cOptions = document.getElementById('cpList').options;
// set a return value string to empty.
var sValues='';
// loop through the options collection to get all values
// and append them to the return value string.
for (var idx=0;idx<cOptions.length;idx++){
sValues += cOptions(idx).value + ',';
}
// send the values in the parent page
sValues = sValues.substr(0,sValues.length-1);
// and close this popup window
window.opener.doUpdate(sValues);
window.close();
}
//-->
</script>
<title>Pop Up List</title>
</head>
<body>
<p><select size="1" name="cpList">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
</select><input type="button" value="Select All" name="selectAll" onclick="selectAllList();"></p>
</body>
</html>
Date Validation Using JavaScript .
Cross-Browser Clipboard Copy .
Loading Images With Remote Scripting .
Why JavaScript In Hyperlinks Is Bad .
Change The Submit Button To Show Waiting For AJAX Response .
European Date Validation Using JavaScript .
Database Results To Client Side Array .
Reading Files With JavaScript .
AJAX For Plain Text And HTML .