Lee wrote:
Mel said:
[...]
can someone help ?
Lee's solution is OK, here's an improvement (to me anyway). The
addresses are only added if there aren't already in the text box.
The HTML is constructed as an array, then written to the window which
may be faster as the list of addresses gets longer.
Creates the window as a local variable.
Gets rid of "javascript" in:
window.open("javascript
:opener.globalHTML",
Script only, HTML unchanged ... have fun!
<script type="text/javascript">
var addressBook=[ "Me", "You", "Him", "Her", "Them" ];
function popup() {
var newWin = window.open('','popup','width=400,height=400,resiz able');
var globalHTML = ['<html><body><form>'];
for (var i=0; i<addressBook.length; i++) {
globalHTML.push(
'<input type="checkbox" name="c" value="'
+ addressBook[i]
+ '"> '
+ addressBook[i]
+ '<br>'
);
}
globalHTML.push(
'<center><input type="button" value="Done"'
+ 'onclick="opener.importAddr(this.form);'
+ 'self.close()"></center>'
+ '</form></body></html>'
);
newWin.document.write(globalHTML.join(''));
newWin.document.close();
}
function importAddr(f) {
var ele = document.forms[0].toAddr;
var addStr = ele.value;
for(var i=0; i<f.c.length; i++) {
if(f.c[i].checked && addStr.indexOf(f.c[i].value) < 0) {
ele.value += f.c[i].value + ";";
}
}
}
</script>
--
Rob