I have the following functions which when called via an href add the item to the list. The email appears in the text area and the id appears in a hidden field. The problem with this is that if the user deletes an email address from the text area the list of ids in the hidden field is incorrect.
What I want to do is convert these functions so that I can dynamically build a multi-select drop down list as well as a hidden list of id's. Then supply a remove button so that when a user removes an email address from the list the hidden field is also updated with the values in the option array.
I would like to end up with code similar to this:
<input type="hidden" name="distids" value="">
<select name="distselect" size="10" multiple style="width:300px;" class="form_field">
<option value=""></option>
</select>
<input type="button" name="remove" id="remove" value="Remove Selected" class="form_submit">
If this makes sense can anyone help?
Code I have below:
<script language="JavaScript" type="text/javascript">
function addemail(journoid, jemail) {
if (document.release2.distlist.value.length > 0) {
document.release2.distlist.value = document.release2.distlist.value + "," + "\n" + jemail;
document.release2.distids.value = document.release2.distids.value + "," + journoid;
} else {
document.release2.distlist.value = jemail;
document.release2.distids.value = journoid;
}
}
function addcat(catid, cat) {
if (document.release2.distlist.value.length > 0) {
document.release2.distlist.value = document.release2.distlist.value + "," + "\n" + cat;
document.release2.distids.value = document.release2.distids.value + "," + catid;
} else {
document.release2.distlist.value = cat;
document.release2.distids.value = catid;
}
}
</script>
<input type="hidden" name="distids" value="">
<textarea cols="" rows="" name="distlist" id="distlist" wrap="hard" class="form_field" style="width:350px;height:300px;"></textarea>
Cheers
Dave
-- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
