How can select shows none

J

Jack

Hello,
<%@ Language=VBScript %>
<%
Response.Write "<SELECT id=select1 name=select1>"
Response.Write "<OPTION value=1>One</OPTION>"
Response.Write "<OPTION value=2>Two</OPTION>"
Response.Write "<OPTION value=3>Three</OPTION>"
Response.Write "</SELECT>"
%>
When open this page,select1 shows "One".I want when open the page,select1
shows none.That is to say,nothing is displayed in select1.
Thank you
 
A

Alex Goodey

<%
Response.Write "<SELECT id=select1 name=select1>"
Response.Write "<OPTION value=1>One</OPTION>"
Response.Write "<OPTION value=2>Two</OPTION>"
Response.Write "<OPTION value=3>Three</OPTION>"
Response.Write "</SELECT>"
%>
 
A

Alex Goodey

Sorry meant to say

Response.Write "<SELECT id=select1 name=select1>"
Response.Write "<OPTION value="""" SELECTED></OPTION>"
Response.Write "<OPTION value=1>One</OPTION>"
Response.Write "<OPTION value=2>Two</OPTION>"
Response.Write "<OPTION value=3>Three</OPTION>"
Response.Write "</SELECT>"
 
B

Blair Bonnett

Just be careful when you are proccessing the response that they have
selected an actual value, rather than the blank one.

If you include the following javascript function within the <head></head>
section, and call it from the form as shown, Javascript will check for a
selection before allowing the form to submit. Note that, if Javascript is
disabled, this won't work, so you MUST also check server-side.

Javascript:
function CheckForm(objForm){
if(objForm.select1.selectedIndex == 0){
alert("You must select an option from the select box.");
return false;}
}

HTML:
<form onSubmit="return CheckForm(this);">

Hope this helps - note that its after midnight here, I'm tired and I wrote
the script off the top of my head and haven't checked it - it *should* work
but I take no responsibility...

Blair
 
J

Jack

Thank you,but
I want none can't be selected.That is to say the value which can be selected
is only "One","Two" or "Three".
I wait anyone's help
 
B

Blair Bonnett

As far as I am aware, that cannot be done. Try the way I suggested before.

Blair
 
D

Dave Anderson

Jack said:
Thank you, but I want none can't be selected.
That is to say the value which can be selected
is only "One","Two" or "Three".

Such a thing is implementation-specific. You might be able to find such a
solution for a small range of browser/OS combinations, but you will have no
guarantee of forward compliance. Consider this, from the HTML 4 spec:

"Visual user agents are not required to present a SELECT
element as a list box; they may use any other mechanism,
such as a drop-down menu."
http://www.w3.org/TR/html401/interact/forms.html#edef-SELECT

The spec merely requires that the SELECT element creates a "menu". It leaves
the details to the implementation.

What exactly are you trying to accomplish? There is certainly a simpler
solution.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
R

Ray at

Yes, what Peter said. By using them, you can have NONE selected by default,
unlike what you can do with a select, but you'll then have no value, just
like if you had an empty leading spot in the select.

Ray at home
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top