element not showing in Request.Form

P

pbd22

Is there any reason why the below function wouldn't
allow the server to "Request.Form("visitors")?

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);}


}
 
V

VK

Is there any reason why the below function wouldn't
allow the server to "Request.Form("visitors")?

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???

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?
 
P

pbd22

Hi.

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="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
</select>
 
T

Thomas 'PointedEars' Lahn

pbd22 said:
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="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</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
 
P

pbd22

OK, thanks.

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
 
V

VK

Hi.

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="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
</select>

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.
 
T

Thomas 'PointedEars' Lahn

VK said:
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="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
<option value="(e-mail address removed)">[email protected]</option>
</select>

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.
[...]

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
 
V

VK

Oh, it is easy then. You just have to recall some HTML basics
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
 
T

Thomas 'PointedEars' Lahn

VK said:
Non sequitur ;-)

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.


PointedEars
 
V

VK

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 ;-)
 
P

pbd22

Hi.

Thanks.

The line of code you added:

selectObject.options[optionRank]=optionObject

Gives me a:
"selectObject has no properties" error.

Peter
 
V

VK

Hi.

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.
 

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
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top