469,621 Members | 1,776 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

Java Script and ASP

I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=fa lse }
function disableServerList()
{document.getElementById("ddlServers").disabled=tr ue }

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"

Mar 6 '06 #1
7 1787
wrote on 06 mrt 2006 in microsoft.public.inetserver.asp.general:
I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=fa lse }
function disableServerList()
{document.getElementById("ddlServers").disabled=tr ue }

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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 6 '06 #2

db****@gmail.com wrote:
I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=fa lse }
function disableServerList()
{document.getElementById("ddlServers").disabled=tr ue }

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.

--
Mike Brind

Mar 7 '06 #3
db****@gmail.com wrote:
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=fa lse }
function disableServerList()
{document.getElementById("ddlServers").disabled=tr ue }

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-Le...ml#ID-94282980

Nor is it an HTML attribute of SELECT:
http://www.w3.org/TR/html401/interac...ml#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.
Mar 7 '06 #4

<db****@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I have a java script

function enableServerList()
{document.getElementById("ddlServers").disabled=fa lse }
function disableServerList()
{document.getElementById("ddlServers").disabled=tr ue }

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.
Mar 7 '06 #5
Anthony Jones wrote:

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 :-)

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 7 '06 #6
"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.
Mar 7 '06 #7
Anthony Jones wrote:
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/interac...#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.
Mar 7 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andy R. | last post: by
4 posts views Thread by lawrence | last post: by
2 posts views Thread by enclume42 | last post: by
reply views Thread by Mircea Pleteriu | last post: by
4 posts views Thread by Don Grover | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.