Can't Add Email To List Box Or Send Email List To Server - Pls. Help

P

pbd22

Hi All.

I am having problems:

1) adding an email to a list, creating a long list box of email
addresses.
2) sending all the email addresses to the server on form submit.

The current problem is that:

1) The input field does not display the added email addresses
(I am currently getting "options.length" is not an object").
2) when i submit the form (with test values) the email addresses
from the list box never appear on the server via Request.Form

Here is my code for adding an email.

function AddSomething() {
var inputvalue = document.getElementById('visitor').value;
var formObject = document.getElementById('invitepresenters');
addOption(formObject,inputvalue,inputvalue);
document.getElementById('visitor').value = "";
}

function addOption(selectObject,optionText,optionValue)
{
var optionObject = new Option(optionText,optionValue)
var optionRank = selectObject.options.length
selectObject.options[optionRank]=optionObject
}

And The HTML:

<input class="input_small" type="text" name="visitor" id="visitor"
value="<%=Request.Form("visitor")%>" />
<input type="button" value="Add" style="position: relative; margin-
top: 6px; display: inline;
padding-bottom: 3px; padding-top: 3px; line-height: 14px;"
onclick="AddSomething();" />

<select class="select_medium" name="visitors" size="7"
multiple="multiple">
</select>

<textarea class="text_xlarge" rows="5" cols="80"
name="invitepresenters" id="invitepresenters" style="margin-bottom:
10px" >


I Would Like the Email To Appear As Such In The Select Box:

<option value="(e-mail address removed)">[email protected]</option>

I appreciate your help.
Peter
 
P

pr

pbd22 wrote:
[...]
Here is my code for adding an email.

function AddSomething() {
var inputvalue = document.getElementById('visitor').value;
var formObject = document.getElementById('invitepresenters');

OK. That's the textarea then.
addOption(formObject,inputvalue,inputvalue);
document.getElementById('visitor').value = "";
}

function addOption(selectObject,optionText,optionValue)
{
var optionObject = new Option(optionText,optionValue)
var optionRank = selectObject.options.length

A textarea doesn't have options.
selectObject.options[optionRank]=optionObject
}

And The HTML:
[...]

<textarea class="text_xlarge" rows="5" cols="80"
name="invitepresenters" id="invitepresenters" style="margin-bottom:
10px" >

Answer: use the select element instead. I suggest you name your form
elements more imaginatively so you can tell them apart. Also read about
form element access in the FAQ.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,074
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top