Simple JavaScript question

Discussion in 'ASP .Net' started by Kevin S. Goff, Mar 12, 2006.

  1. Hi....I realize this is a really basic question....

    I have a webform (in VS.NET 2005). It has (among other things) a
    combobox and a command button. At the beginning, the command button
    is disabled....on the selectedindexchanged event of the combobox, I
    want to enable the command button

    Only way I know to do it is in the code-behind .CS file with a
    postback, but I'd rather do it with Javascript....except I really
    don't know the syntax very well.

    Assuming my two controls were cboItem and btnSave, what would the
    syntax be (in the HTML) to enable btnSave when cboItem changes?

    Thanks a lot in advance,
    Kevin
     
    Kevin S. Goff, Mar 12, 2006
    #1
    1. Advertising

  2. Kevin S. Goff

    barry Guest

    The way I would do it so as not to get the post back would be to make the
    dropdown a html control then
    the javascript would look like this

    document.body.all.item("btnSave").disabled = false;


    "Kevin S. Goff" <kgoff@commongroundsolutions> wrote in message
    news:...
    > Hi....I realize this is a really basic question....
    >
    > I have a webform (in VS.NET 2005). It has (among other things) a
    > combobox and a command button. At the beginning, the command button
    > is disabled....on the selectedindexchanged event of the combobox, I
    > want to enable the command button
    >
    > Only way I know to do it is in the code-behind .CS file with a
    > postback, but I'd rather do it with Javascript....except I really
    > don't know the syntax very well.
    >
    > Assuming my two controls were cboItem and btnSave, what would the
    > syntax be (in the HTML) to enable btnSave when cboItem changes?
    >
    > Thanks a lot in advance,
    > Kevin
     
    barry, Mar 12, 2006
    #2
    1. Advertising

  3. Hi,

    barry wrote:
    > The way I would do it so as not to get the post back would be to make the
    > dropdown a html control then
    > the javascript would look like this
    >
    > document.body.all.item("btnSave").disabled = false;


    Why not rather use the standard way to do this? The "all" property
    exists only in IE and is a fossile from the past.

    The DOM Level 2 way is:

    <select onchange="document.getElementById('btnSave').disabled=false;">
    ....

    Also, the combo doesn't have to be a HTML control. You can use an
    ASP.NET listbox, with AutPostback = false, and use SetAttribute to set
    the javascript code.

    HTH,
    Laurent
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch
     
    Laurent Bugnion, Mar 12, 2006
    #3
    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. Replies:
    0
    Views:
    566
  2. Kevin Spencer

    Re: Simple Simple question!!!

    Kevin Spencer, Jun 25, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    673
    Kevin Spencer
    Jun 25, 2004
  3. Daniel Frey

    Simple Question - Simple Answer?

    Daniel Frey, Dec 28, 2004, in forum: XML
    Replies:
    4
    Views:
    846
    Daniel Frey
    Jan 12, 2005
  4. Oli

    simple simple question

    Oli, Jan 26, 2004, in forum: ASP General
    Replies:
    10
    Views:
    379
    Roland Hall
    Jan 26, 2004
  5. Peter Bailey

    simple, simple array question

    Peter Bailey, Apr 8, 2008, in forum: Ruby
    Replies:
    7
    Views:
    217
    Peter Bailey
    Apr 8, 2008
Loading...

Share This Page