hi everyone,
i'm new to javascript. i have the following code appending emails together together into a textbox when items are selected from a listbox. i have two issues.
1. the first selection passed to the emailcc textbox always appears as:
, johnsmith@home.ca
2. i'd like the ability to click on the listbox again to remove the email addresses selected from the textbox if email addresses in the list box are clicked a second time.
whats the best way to accomplish this? thanks.
<script type="text/javascript" language="JavaScript">
function Copy_listbox(){
document.emailaddresses.emailcc.value += ", " + document.emailaddresses.SelectEMailccListBox.value;
}
</script>
Javascript: adding/removing values from txtbox from listbox
Moderator: General Moderators
Re: Javascript: adding/removing values from txtbox from list
If the goal is to submit multiple email addresses in a form, try
With the multiple attribute, the user is able to select more than one option by holding the Shift or Ctrl key while clicking. The [] in the name attribute means that all values submitted with the name emails[] (all selected options) should be grouped together in an array named emails.
Also, see this example in the manual.
Code: Select all
<select multiple name="emails[]">Also, see this example in the manual.