Java Script and ASP

Discussion in 'ASP General' started by dbabin@gmail.com, Mar 6, 2006.

  1. Guest

    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"
     
    , Mar 6, 2006
    #1
    1. Advertising

  2. Evertjan. Guest

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

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

  3. Mike Brind Guest

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

    --
    Mike Brind
     
    Mike Brind, Mar 7, 2006
    #3
  4. 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=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.
     
    Dave Anderson, Mar 7, 2006
    #4
  5. <> wrote in message
    news:...
    > 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.
     
    Anthony Jones, Mar 7, 2006
    #5
  6. 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.
     
    Bob Barrows [MVP], Mar 7, 2006
    #6

  7. >"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.
     
    Anthony Jones, Mar 7, 2006
    #7
  8. 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/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.
     
    Dave Anderson, Mar 7, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rajat
    Replies:
    3
    Views:
    705
    Jorgen Grahn
    Jan 8, 2010
  2. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    565
    Jan Kaliszewski
    Jan 7, 2010
  3. Simon Wigzell

    Calling an asp script from an asp script

    Simon Wigzell, May 8, 2004, in forum: ASP General
    Replies:
    4
    Views:
    175
    Lance Wynn
    May 10, 2004
  4. Speed Knownas
    Replies:
    12
    Views:
    310
    Mike Stephens
    Jun 25, 2009
  5. Replies:
    3
    Views:
    126
Loading...

Share This Page