I have these 2 pages. One page is a form with a text box field.

The other one is an adress book pop-up page kinda thing.
When user opens adress book pop-up, they click on a link and the textbox field in the form page is populated. If they click further on the array of the links on address page, the values are seperated by a comma.

How do I limit (from the function AddTo()) the entry (or auto population) to just one, instead of comma seperated multiple?

Thanks in advance.


<!-- Form Page -->
<script>
function AddTo(addr) {
var dms = document.compose_form.to_name;
if(dms.value.length > 0) dms.value += ", ";
document.compose_form.to_name.value += addr;
}
</script>

<table border="0" cellspacing="0" cellpadding="2">
<form ... name="compose_form">
<tr><td class="fieldtitle">To/td>
<td><input type="text" class="textbox" name="to_name" value=""></td><td><a href="#" onclick="window.open('abook.html',
'win1','width=350,height=150,scrollbars=yes')">Contact book</a></td>
</tr>
<tr>
<td>
<input type="submit" class="databutton" value="Send"></td>
<td colspan="2">&nbsp;</td>
</tr></form></table>
<!-- abook.html Adress book page -->
<script type="text/javascript">
<!--
function addTo(to_list) {
var isAdded = new Array();
if(isAdded[to_list]) return;
isAdded[to_list] = 1;
var df = document.theForm;
var wo = window.opener;
wo.AddTo(to_list);
}

// -->
</script>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td nowrap><a name="to_link_2" href="javascript:if(window.navigator.appName!='Netscape') to_link_2.outerHTML='<b>[---]</b>';addTo('demo');" >[Add]</a> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td width="88%">demo</td>
</tr>
<tr>
<td nowrap><a name="to_link_1" href="javascript:if(window.navigator.appName!='Netscape') to_link_1.outerHTML='<b>[---]</b>';addTo('admin');" >[Add]</a> &nbsp;&nbsp;&nbsp;&nbsp;</td>
<td width="88%">admin</td>
</tr>
</table>