The form just starts with this:
<select class="select_medium" name="visitors" id="visitors" size="7"></
select>
And the testAdd() function adds email addresses to the select.
Then i submit the form but the "visitors" element is never one of the
keys
(yes, it is inside the form tag).
Any ideas???
Thanks
function testAdd() {
try
{
var inputvalue = document.getElementById('visitor').value;
var formObject = document.getElementById('visitors');
var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+
([a-zA-Z])+/;
var goodemail;
var err = "";
if(pattern.test(inputvalue)){
goodemail = true;
}else{
if (inputvalue == "")
alert("You must type in an email address");
else
{
alert("Bad email address syntax.\n Check for format
errors.");
goodemail = false;
}
}
if (goodemail == true)
{
if (inputvalue.indexOf("vodafone") != -1)
{
addOption(formObject,inputvalue,inputvalue);
document.getElementById('visitor').value = "";
} else
{
alert("You can only send to other vodafone
employees");
}
}
}catch(e){alert(e.message);}
}
They may appear if you post the relevant code ;-) In your case it is
addOption function, the posted e-mail testing code is not relevant.
Also what do you want to be submitted? A particular option in the list
or the last added option?
Yes, sorry. That function would have helped:
function addOption(selectObject,optionText,optionValue) {
var optionObject = new Option(optionText,optionValue)
var optionRank = selectObject.options.length
selectObject.options[optionRank]=optionObject
}
I want to submit all options in the list. Eg.
<select class="select_medium" name="visitors" id="visitors" size="7">
<option value="pe...@google.com">pe...@google.com</option>
<option value="pa...@google.com">pa...@google.com</option>
<option value="ma...@google.com">ma...@google.com</option>
<option value="jo...@google.com">jo...@google.com</option>
</select>
Although the `id' attribute seems superfluous, your posted code does not
provide a good reason why server-side Request.Form("visitors") would be
unavailable. Make sure that your submitting markup is valid, and try again.
This is rather an ASP (.NET) problem. I suggest you ask in the appropriate
newsgroup instead.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300...@news.demon.co.uk>
I thought there might be something in my javascript logic that was
missing the mark.
I will do as you suggest and thanks for piping in.
Best,
Pbd
Oh, it is easy then. You just have to recall some HTML basics (Thomas
has failed on it miserably alas):
1) On submit browser sends not each and every option value in select,
but only options _selected_ by the user.
2) In order to be able to have several - or all - options selected at
once one has to set MULTIPLE flag on.
This way the proper SELECT element declaration will be:
<select class="select_medium" name="visitors" size="7" multiple>
or if you need to accommodate it for XHTML validator then
<select class="select_medium" name="visitors" size="7"
multiple="multiple">
This way the proper Javascript code might be:
function addOption(selectObject,optionText,optionValue) {
var optionObject = new Option(optionText,optionValue);
var optionRank = selectObject.options.length;
selectObject.options[optionRank]=optionObject;
selectObject.options[optionRank].selected = true;
}
Enjoy.
Nothing you say has anything to do with the original problem:
| Is there any reason why the below function wouldn't
| allow the server to "Request.Form("visitors")?
It might be that the original problem was not well described, and that the
additional posting clarified it (which I would have ignored), but so far for
"failing miserably".
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
> Nothing you say has anything to do with the original problem:
>
> | Is there any reason why the below function wouldn't
> | allow the server to "Request.Form("visitors")?
>
> It might be that the original problem was not well described,
> and that the additional posting clarified it (which I would have
> ignored), but so far for "failing miserably".
Non sequitur ;-) In your last response you have quoted the relevant
part of OP's response you were answering to (this is the only right
quoting you are always doing, right?) and it contains exactly all you
needed to see the problem:
http://groups.google.com/group/comp.lang.javascript/msg/b6a767ef229e7585
You should not be using foreign words if you are unable to apply them
properly. "Non sequitur" means that there is a conclusion in the
aforementioned statement that would not follow from a premise; there
is no such thing there.
1) One should always quote what he's replying to but not above it.
2) Thomas Lahn always follows this rule as many time stated by him.
3) Thomas Lahn quoted OP's code for addOption function and OP's
explanation of the desired behavior.
http://groups.google.com/group/comp.lang.javascript/msg/b6a767ef229e7585
4) In the response Thomas Lahn stated that "Although the `id'
attribute seems superfluous, your posted code does not provide a good
reason why server-side Request.Form("visitors") would be unavailable."
5) When being criticized Thomas Lahn stated that
"It might be that the original problem was not well described, and
that the additional posting clarified it (which I would have
ignored)."
Non sequitur.
P.S. If you want another shot in formal logic or semantic analysis
then just let me know ;-)
Thanks.
The line of code you added:
selectObject.options[optionRank]=optionObject
Gives me a:
"selectObject has no properties" error.
Peter
That means (99% of probability) that selectObject indeed doesn't
exist. You either mistyped the name or broke the code somewhere. Post
the surrent source - an actual URL would be completely terrific.
thanks again,
peter
> i sent this link to your personal account.
whose?
[please always quote on usenet]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Thanks again.
> To the guy who asked me for a link :)
> VK - just above my last post.
What is "above" on usenet?