Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Grey out drop down list

New Here ,
Mar 22, 2007 Mar 22, 2007
H,i,

Does any one know how you can set a drop down list as inactive and greyed out in code?
I am using ASP and javascript.

regards

Fifo
TOPICS
Server side applications
2.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2007 Mar 22, 2007
There's an HTML tag to do it. Add
disabled="disabled"
as an attribute

HTH,

Piers


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2007 Mar 22, 2007
fifo85 wrote:

> H,i,
>
> Does any one know how you can set a drop down list as inactive and greyed out in code?
> I am using ASP and javascript.
>
<select disabled>

http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select3
Mick

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 22, 2007 Mar 22, 2007
Thaks for that Mick
One more thng. How would i be able to set the drop down inactive within an if statement using javascript,
Basically i want to control the disabled attribute based on the condition in the if statement.
Hence i am looking for something like: -

<html>
<body>

<form action="">
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat" selected="selected">Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
<%if (condition) {
Select("cars") disabled="disabled"; //Something like this hence controlling the disabled state outside of the
} //select clause.

</body>
</html>

I hope am making sense,

Regards
Fifo
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2007 Mar 22, 2007
fifo85 wrote:

> Thaks for that Mick
> One more thng. How would i be able to set the drop down inactive within an if
> statement using javascript,
> Basically i want to control the disabled attribute based on the condition in
> the if statement.
> Hence i am looking for something like: -
>
> <html>
> <body>
>
> <form action="">
> <select name="cars">
> <option value="volvo">Volvo</option>
> <option value="saab">Saab</option>
> <option value="fiat" selected="selected">Fiat</option>
> <option value="audi">Audi</option>
> </select>
> </form>
<script type="text/javascript">

if(pope=="catholic"){
document.forms[0].cars.disabled=true;
}
</script>

Mick

> <%if (condition) {
> Select("cars") disabled="disabled"; //Something
> like this hence controlling the disabled state outside of the
> }
> //select clause.
>
> </body>
> </html>
>
> I hope am making sense,
>
> Regards
> Fifo
>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 23, 2007 Mar 23, 2007
Thanks for the response Mick,

Just one question, What is the document.forms[0] suppose to be?
I have tried the name of my asp page followed by forms[0] followed by the name of my drop down

i.e. CategoryListing.asp.forms[0].GroupDD.disabled=TRUE;

but dreamweaver doesn't like it. it throws an error message.
I assume that form[0] should be replaced by the form name of the form that contains the drop down.

How is the syntax mean't to be?

Thanks in Advance

Fifo
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2007 Mar 23, 2007
fifo85 wrote:

> Thanks for the response Mick,
>
> Just one question, What is the document.forms[0] suppose to be?
> I have tried the name of my asp page followed by forms[0] followed by the name
> of my drop down

"document.forms[0]" is a reference to the first form in the document.
Since you didn't name your form, I assumed you have only one form in
your document. Normally, you would name your form
<form name="foo">
Then you can reference it directly:

document.forms["foo"]

To disable a select object named "bar" in a form name "foo", the
following will accomplish the task:

document.forms["foo"].elements["bar"].disabled=true;
//or as a shortcut:
document.foo.bar.disabled=true;

The "document" is a reference to your current document, not the title.
This assumes a non-framed environment.
Mick

>
> i.e. CategoryListing.asp.forms[0].GroupDD.disabled=TRUE;
>
> but dreamweaver doesn't like it. it throws an error message.
> I assume that form[0] should be replaced by the form name of the form that
> contains the drop down.
>
> How is the syntax mean't to be?
>
> Thanks in Advance
>
> Fifo
>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2007 Mar 26, 2007
LATEST
Thanks Mick,

I have tried entering the following code

document.GroupForm.GroupDD.disabled=TRUE;
where GroupForm is the name of the form
GroupDD is the name of the drop down

but i get the following error message from the web browser when i run it

Error Type:
Microsoft JScript runtime (0x800A1391)
'document' is undefined
/DCASuppliersDatabase/CategoryListing.Mod.asp, line 180

Why is this ?

Regards
Feroz
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines