Java Script and ASP

D

dbabin

I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=false }
function disableServerList()
{document.getElementById("ddlServers").disabled=true }

This greys out a drop down list as expected. The problem is, when I
click on the "get Report" button, I need a way to say in asp code:

if the drop down list ddlServers is disabled then bla
else
bla

The apparent problem is that when java disables it, the ddl properties
page still holds on to an enabled=true property.

I need to be able to write a code(on the asp code page) to get the
status of enabled true or false for a Drop Down List that java script
has "disabled"
 
E

Evertjan.

wrote on 06 mrt 2006 in microsoft.public.inetserver.asp.general:
I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=false }
function disableServerList()
{document.getElementById("ddlServers").disabled=true }

This greys out a drop down list as expected.


This above is clientside javascript code
The problem is, when I
click on the "get Report" button, I need a way to say in asp code:

if the drop down list ddlServers is disabled then bla
else
bla

ASP is [a platform for] serverside code in languages
like vbscript and j[ava]script.

Serverside code cannot access clientside values.
The apparent problem is that when java disables it,

Java is another language altogether,
has nothing to do with javascript but the name.
the ddl properties
page still holds on to an enabled=true property.

I don't understand what you mean.
What is a "page" that "still holds on"?

It is the browser DOM that contains the enabled, I presume.
I need to be able to write a code(on the asp code page)

What is an "ASP-code page"?

There is a .asp file on the server that is executed on the server,
executing it's asp code and rendering html content that is sent to the
client. This html code can contain the source of to be executed
clientside code [in javascript, among others]
to get the
status of enabled true or false for a Drop Down List that java script

javascript, not java script
has "disabled"

The browser DOM of the list seems to contain "disabled" in the browser.
ASP works serverside and has no knowledge of browsers or their DOM.

So only clientside code can enable it again.

btw, I hope that by ASP you do not mean ASP.net ????
 
M

Mike Brind

I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=false }
function disableServerList()
{document.getElementById("ddlServers").disabled=true }

This greys out a drop down list as expected. The problem is, when I
click on the "get Report" button, I need a way to say in asp code:

if the drop down list ddlServers is disabled then bla
else
bla

The apparent problem is that when java disables it, the ddl properties
page still holds on to an enabled=true property.

I need to be able to write a code(on the asp code page) to get the
status of enabled true or false for a Drop Down List that java script
has "disabled"

Two possible solutions: Either use ASP to set the disabled property
rather than JavaScript. That way the value is available to any other
ASP code you write. Or, change your javascript function so that it
writes a value to a hidden form field depending on whether disabled =
true or false. You can access that through ASP.
 
D

Dave Anderson

I have a java script

Do you walk on car pet? The terms "javascript" and "Java script" describe
two things wholly distinct from one another.


function enableServerList()
{document.getElementById("ddlServers").disabled=false }
function disableServerList()
{document.getElementById("ddlServers").disabled=true }

This greys out a drop down list as expected. The problem is,
when I click on the "get Report" button, I need a way to say
in asp code:

The apparent problem is that when java disables it, the ddl
properties page still holds on to an enabled=true property.

You never manipulated an "enabled" property. You manipulated a "disabled"
property.


I need to be able to write a code(on the asp code page) to
get the status of enabled true or false for a Drop Down List
that java script has "disabled"

There is no concept of "enabled" unless you assign it yourself. It's not in
the DOM:
http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-94282980

Nor is it an HTML attribute of SELECT:
http://www.w3.org/TR/html401/interact/forms.html#edef-SELECT



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

Anthony Jones

I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=false }
function disableServerList()
{document.getElementById("ddlServers").disabled=true }

This greys out a drop down list as expected. The problem is, when I
click on the "get Report" button, I need a way to say in asp code:

if the drop down list ddlServers is disabled then bla
else
bla

The apparent problem is that when java disables it, the ddl properties
page still holds on to an enabled=true property.

I need to be able to write a code(on the asp code page) to get the
status of enabled true or false for a Drop Down List that java script
has "disabled"

It's embarrasing the number of unhelpfully critical replies you have
received.

The disabled state of the control isn't persisted between form submissions.
Add a hidden field to hold the enabled/disabled state of the server list and
modify it's value in the functions.

In ASP code (note guys this is an ASP question) read the value of the hidden
field and use it something like:-

<select id="serverList" disabled="<%=Request.Form("serverListDisabled")%>" >


Anthony.
 
B

Bob Barrows [MVP]

Anthony said:
It's embarrasing the number of unhelpfully critical replies you have
received.

Huh? You are about to give the same answer that was given by Mike Brind in
this thread ...

Actually, your reply is less "helpful" than his since he suggested two
alternatives compared to your single alternative :)
 
A

Anthony Jones

"Huh? You are about to give the same answer that was given by Mike Brind in
this thread ...
Actually, your reply is less "helpful" than his since he suggested two
alternatives compared to your single alternative :)


:$ Yup yet more embarrasment. Mike is the only helpful guy in this thread
:)

Anthony.
 
D

Dave Anderson

Anthony said:
It's embarrasing the number of unhelpfully critical replies
you have received.

A reply that gets the OP to think about the causes of behavior is FAR MORE
helpful than one that just tells him one possible solution. Teach a man to
fish.

The disabled state of the control isn't persisted between form
submissions.

Well...it sort of is:

"Disabled controls cannot be successful"
http://www.w3.org/TR/html401/interact/forms.html#adef-disabled

Therefore, if (Request.Form.Count && !Request.Form("ddlServers").Count),
then the control certainly was not successful, so there is a good chance it
was disabled.

And when I say there is a good chance, I mean that you can easily design
your application so that this condition is sufficient to assume it was
disabled. More importantly, you can make that condition the sole basis for
assigning the DISABLED attribute.



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

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top