Is there any way to make a SELECT field in HTML as a read only field?

Discussion in 'Javascript' started by datactrl, May 19, 2004.

  1. datactrl

    datactrl Guest

    Hi, all

    Is there any way to make a SELECT field in HTML as a read only field?

    Jack
     
    datactrl, May 19, 2004
    #1
    1. Advertising

  2. datactrl

    Ivo Guest

    "datactrl" aka Jack asks
    > Is there any way to make a SELECT field in HTML as a read only field?
    >


    It is read-only by design, as far as i am aware. Perhaps you mean making it
    impossible to alter the selected option(s). Then

    <select onfocus="this.nextSibling.focus()">

    works fine (if the next sibling is another form element).

    <select onfocus="window.focus()">

    makes the list flash open for a moment.
    You realize that javascript will not available on many machines.
    HTH
    Ivo
     
    Ivo, May 19, 2004
    #2
    1. Advertising

  3. datactrl

    datactrl Guest

    Hi, Ivo
    Thanks a lot. Yes, I mean making it impossible to alter the selected option.
    I try the way you advised. It works the most times but sometimes the drop
    list stays there insteead of flashing a moment. Do you have the same
    problem? I use IE6.

    Jack



    "Ivo" <> wrote in message
    news:40aba129$0$89222$...
    > It is read-only by design, as far as i am aware. Perhaps you mean making

    it
    > impossible to alter the selected option(s). Then
    >
    > <select onfocus="this.nextSibling.focus()">
    >
    > works fine (if the next sibling is another form element).
    >
    > <select onfocus="window.focus()">
    >
    > makes the list flash open for a moment.
    > You realize that javascript will not available on many machines.
    > HTH
    > Ivo
    >
    >
     
    datactrl, May 20, 2004
    #3
  4. datactrl

    Alberto Guest

    Yeah I noticed.
    Ok try:
    <select onChange="this.selectedIndex=0">
    You can change the zero (which means the very first option) with a number
    representing the index of the option that you want to keep selected EVEN if
    the user attempts to select another one.
    ps note that selectedIndex is CASE SENSITIVE: the i must be uppercase

    ciao
    Alberto
    http://www.unitedscripters.com/



    "datactrl" <> ha scritto nel messaggio
    news:...
    > Hi, Ivo
    > Thanks a lot. Yes, I mean making it impossible to alter the selected

    option.
    > I try the way you advised. It works the most times but sometimes the drop
    > list stays there insteead of flashing a moment. Do you have the same
    > problem? I use IE6.
    >
    > Jack
    >
    >
     
    Alberto, May 20, 2004
    #4
  5. datactrl

    datactrl Guest

    It works on when the original Selected Value is fixed. But my problem is the
    selected value comes from a database on server. Just can't change back to
    the original unless the original has been saved.

    Jack
    "Alberto" <> wrote in message
    news:c8gut3$34s$...
    > Yeah I noticed.
    > Ok try:
    > <select onChange="this.selectedIndex=0">
    > You can change the zero (which means the very first option) with a number
    > representing the index of the option that you want to keep selected EVEN

    if
    > the user attempts to select another one.
    > ps note that selectedIndex is CASE SENSITIVE: the i must be uppercase
    >
    > ciao
    > Alberto
    > http://www.unitedscripters.com/
    >
    >
    >
    > "datactrl" <> ha scritto nel messaggio
    > news:...
    > > Hi, Ivo
    > > Thanks a lot. Yes, I mean making it impossible to alter the selected

    > option.
    > > I try the way you advised. It works the most times but sometimes the

    drop
    > > list stays there insteead of flashing a moment. Do you have the same
    > > problem? I use IE6.
    > >
    > > Jack
    > >
    > >

    >
    >
     
    datactrl, May 20, 2004
    #5
    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. Shane Mingins
    Replies:
    2
    Views:
    396
    Woolly Mittens
    Sep 18, 2003
  2. keithb
    Replies:
    2
    Views:
    8,070
    keithb
    Jun 7, 2006
  3. Cas
    Replies:
    0
    Views:
    971
  4. Lloyd Sheen
    Replies:
    3
    Views:
    292
    Cowboy \(Gregory A. Beamer\)
    Mar 18, 2008
  5. Cas
    Replies:
    0
    Views:
    998
Loading...

Share This Page