radio button

Discussion in 'Javascript' started by stefano, Feb 8, 2006.

  1. stefano

    stefano Guest

    HI, I have aproblem with XHTML radio button.

    <form name=" form">
    <input name="radio" type="radio" onclick="return false" />
    <input name="radio" type="radio" onclick="return false" />
    <input name="radio" type="radio" onclick="return false" />
    </form>

    I want that when the radio is clicked, it is not checked. in other word
    I want the click has no effect on the radio.
    in IE it work, but in FireFox, the first click check the radio, while
    the second, the tirdth, etc.. don't check the radio.
    Why the first click is different than the others?
     
    stefano, Feb 8, 2006
    #1
    1. Advertising

  2. stefano

    Erwin Moller Guest

    stefano wrote:

    > HI, I have aproblem with XHTML radio button.
    >
    > <form name=" form">
    > <input name="radio" type="radio" onclick="return false" />
    > <input name="radio" type="radio" onclick="return false" />
    > <input name="radio" type="radio" onclick="return false" />
    > </form>
    >
    > I want that when the radio is clicked, it is not checked. in other word
    > I want the click has no effect on the radio.
    > in IE it work, but in FireFox, the first click check the radio, while
    > the second, the tirdth, etc.. don't check the radio.
    > Why the first click is different than the others?


    Hi

    I think a radio object expects one option to be checked.
    If you create some options, many browsers will even check the first if you
    do not set another one explicitly (CHECKED).

    So I think you are relying on strange/buggy behaviour in whatever it is you
    are trying to achieve. :)

    Regards,
    Erwin Moller
     
    Erwin Moller, Feb 8, 2006
    #2
    1. Advertising

  3. stefano

    News Guest

    "stefano" <> wrote in message
    news:...
    > HI, I have aproblem with XHTML radio button.
    >
    > <form name=" form">
    > <input name="radio" type="radio" onclick="return false" />
    > <input name="radio" type="radio" onclick="return false" />
    > <input name="radio" type="radio" onclick="return false" />
    > </form>
    >
    > I want that when the radio is clicked, it is not checked. in other word
    > I want the click has no effect on the radio.
    > in IE it work, but in FireFox, the first click check the radio, while
    > the second, the tirdth, etc.. don't check the radio.
    > Why the first click is different than the others?
    >


    <script type="text/javascript">
    function click4(myName)
    {
    document.getElementById(myName).checked=true;
    }
    </script>

    <form name=" form">
    <input name="radio1" type="radio" onclick="click4()" />
    <input name="radio2" type="radio" onclick="click4()" />
    <input name="radio3"type="radio" onclick="click4()" />
    <input name="radio4" type="radio" onclick="click4()" />
    </form>


    Totus possum, totum Deum.
    Totus ero, totum meum.
    WSW
     
    News, Feb 8, 2006
    #3
  4. stefano

    News Guest

    Sorry copied wrong <form> try this one

    Sorry I just copied your form forgot the changes I made to it



    function click4(myName)
    {
    document.getElementById(myName).checked=true;
    }
    </script>

    <form name="form">
    <input name="radio" id="r1" type="radio" onclick="click4('r4')"/>
    <input name="radio" id="r2" type="radio" onclick="click4('r4')"/>
    <input name="radio" id="r3" type="radio" onclick="click4('r4')"/>
    <input name="radio" id="r4" type="radio" onclick="click4('r4')"/>
    </form>
     
    News, Feb 8, 2006
    #4
  5. stefano

    Lee Guest

    Re: Sorry copied wrong <form> try this one

    News said:
    >
    >Sorry I just copied your form forgot the changes I made to it


    Please don't change the subjects of message threads.
     
    Lee, Feb 8, 2006
    #5
  6. stefano

    News Guest

    Re: Sorry copied wrong <form> try this one

    "Lee" <> wrote in message
    news:...
    > News said:
    >>
    >>Sorry I just copied your form forgot the changes I made to it

    >
    > Please don't change the subjects of message threads.
    >


    OK won't again
     
    News, Feb 8, 2006
    #6
  7. stefano

    RobG Guest

    stefano wrote:
    > HI, I have aproblem with XHTML radio button.
    >
    > <form name=" form">
    > <input name="radio" type="radio" onclick="return false" />
    > <input name="radio" type="radio" onclick="return false" />
    > <input name="radio" type="radio" onclick="return false" />
    > </form>
    >
    > I want that when the radio is clicked, it is not checked. in other word
    > I want the click has no effect on the radio.


    Then disable it - no script required:

    <input name="radio" type="radio" disabled="disabled" />

    Though a better way is to use script to disable it since you will likely
    want to use script later to enable it.

    It's probably not a good idea to give the buttons a name that is the
    same as the value of an HTML attribute, perhaps make the name
    'radioGroup01' or similar.

    For what it's worth, the following does what you ask (provided script is
    enabled):

    <input name="radio" type="radio" onclick="this.checked=false;" />


    But it does not guarantee that a user can't check the button.


    > in IE it work, but in FireFox, the first click check the radio, while
    > the second, the tirdth, etc.. don't check the radio.
    > Why the first click is different than the others?


    What it does for me is keep whichever button I click on first checked,
    essentially disabling subsequent clicks. What should 'return false' do
    when a radio button is clicked?


    --
    Rob
     
    RobG, Feb 9, 2006
    #7
  8. stefano

    Lee Guest

    Re: Sorry copied wrong <form> try this one

    Duncan Booth said:
    >
    >Lee wrote:
    >
    >> News said:
    >>>
    >>>Sorry I just copied your form forgot the changes I made to it

    >>
    >> Please don't change the subjects of message threads.
    >>

    >On the contrary, always update the subject when it is appropriate so to do.
    >
    >Usenet messages are threaded by reference header, not by subject, so you
    >won't break the threads changing the subject except for people using broken
    >newsreader programs.


    Of course it doesn't break the threading, but in some (many? most?)
    readers, when viewing thread summaries, the thread is titled according
    to its most recent subject.
     
    Lee, Feb 9, 2006
    #8
  9. Re: Sorry copied wrong <form> try this one

    JRS: In article <>, dated Wed, 8 Feb 2006
    13:48:26 remote, seen in news:comp.lang.javascript, Lee
    <> posted :
    >News said:
    >>
    >>Sorry I just copied your form forgot the changes I made to it

    >
    >Please don't change the subjects of message threads.


    Disregard that. It's meaningless (a thread does not have a subject;
    articles have subjects) and its intent is wrong.

    The subject line can and should be changed if the topic of the article
    changes enough to justify it.

    There's no need to pander to inferior newsreaders that cannot thread
    articles on References.

    However, the subject line should not be changed arbitrarily or in the
    manner in which "News" changed it.

    "News" has provided a demonstration of one of the stupidities of Lahn-
    style attributions; they become useless where the "author's name" is not
    a name, or is unreasonably short or common.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME ©
    Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
    Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
    No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
     
    Dr John Stockton, Feb 9, 2006
    #9
  10. stefano

    Lee Guest

    Re: Sorry copied wrong <form> try this one

    Dr John Stockton said:
    >
    >JRS: In article <>, dated Wed, 8 Feb 2006
    >13:48:26 remote, seen in news:comp.lang.javascript, Lee
    ><> posted :
    >>News said:
    >>>
    >>>Sorry I just copied your form forgot the changes I made to it

    >>
    >>Please don't change the subjects of message threads.

    >
    >Disregard that. It's meaningless (a thread does not have a subject;
    >articles have subjects) and its intent is wrong.


    What a silly thing to say.

    I don't know of any newsreaders that thread by subject line, but I do
    know of more than one that display only the most recent subject line
    in a thread when threads are collapsed.
     
    Lee, Feb 9, 2006
    #10
  11. stefano

    Lee Guest

    Re: Inappropriate subjects (was Re: Sorry copied wrong <form> try this one)

    Duncan Booth said:

    >You seem to be missing the point entirely though: the change of subject
    >which sparked this was inappropriate and pointing this out to the OP would
    >have been fine, but a blanket 'don't change subjects' is plain wrong.


    I understand the point. The blanket statement that the admonision "don't
    change subjects" is wrong, is wrong.

    I didn't make my point as clearly as I might have. What I am against
    is changing the subject entirely so that it is no longer recognizable,
    as was done to this thread.

    I think we agree.
     
    Lee, Feb 10, 2006
    #11
  12. stefano

    Lee Guest

    Re: Inappropriate subjects (was Re: Sorry copied wrong <form> try this one)

    Lee said:
    >
    >Duncan Booth said:
    >
    >>You seem to be missing the point entirely though: the change of subject
    >>which sparked this was inappropriate and pointing this out to the OP would
    >>have been fine, but a blanket 'don't change subjects' is plain wrong.

    >
    >I understand the point. The blanket statement that the admonision "don't
    >change subjects" is wrong, is wrong.
    >
    >I didn't make my point as clearly as I might have. What I am against
    >is changing the subject entirely so that it is no longer recognizable,
    >as was done to this thread.
    >
    >I think we agree.


    On re-reading I notice that my "admonision" was wrong. It should have
    been an "admonition", of course.
     
    Lee, Feb 10, 2006
    #12
    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. Scott D Johnson
    Replies:
    1
    Views:
    1,134
    Scott D Johnson
    Sep 27, 2006
  2. Jan C. Faerber
    Replies:
    0
    Views:
    644
    Jan C. Faerber
    Jun 30, 2009
  3. tshad
    Replies:
    6
    Views:
    7,302
    Alexey Smirnov
    Nov 26, 2009
  4. Martin
    Replies:
    8
    Views:
    3,475
    Jan C. Faerber
    Nov 24, 2009
  5. Hiten
    Replies:
    1
    Views:
    708
    Vidar Petursson
    May 26, 2004
Loading...

Share This Page