Disable all form field except submit button

Discussion in 'Javascript' started by millw0rm@gmail.com, Jun 22, 2006.

  1. Guest

    i got a form full of radio buttons appx. 60-70, depends on the page.
    Some times 60, sometimes 55.... After certain period of time, i want to
    disable or make readonly all the radio button inside the form except
    submit button.

    i have done the timing part, i hav setup a running clock which will
    trigger the event @ XX amount of time but i m unable to make the radio
    button disable or read only! remember submit button shld be available
    to submit the form....

    can ou please help???/


    thnx
    , Jun 22, 2006
    #1
    1. Advertising

  2. Jeremy Guest

    wrote:
    > i got a form full of radio buttons appx. 60-70, depends on the page.
    > Some times 60, sometimes 55.... After certain period of time, i want to
    > disable or make readonly all the radio button inside the form except
    > submit button.
    >
    >
    > thnx
    >


    You'll probably want to make them read-only, as making them disabled
    will prevent their values from being submitted to the server.

    function makeAllReadOnlyExceptSubmit()
    {
    var f = document.getElementById("idOfYourForm");
    var inputs = f.getElementsByTagName("input");
    for(var i = 0; i < inputs.length; i++)
    if(inputs.type != "submit")
    inputs.readOnly = true;
    }
    Jeremy, Jun 22, 2006
    #2
    1. Advertising

  3. Jeremy Guest

    Jeremy wrote:
    > function makeAllReadOnlyExceptSubmit()
    > {
    > var f = document.getElementById("idOfYourForm");
    > var inputs = f.getElementsByTagName("input");
    > for(var i = 0; i < inputs.length; i++)
    > if(inputs.type != "submit")
    > inputs.readOnly = true;
    > }


    Actually, you probably don't even need to check whether it's a submit
    button or not - I don't think making a submit button read-only will
    prevent it from being operational (techically it's ALWAYS read-only
    since the user can't affect its value).

    Jeremy
    Jeremy, Jun 22, 2006
    #3
  4. Guest

    not working!!! radio buttons are still available to select and change
    value


    Jeremy wrote:
    > Jeremy wrote:
    > > function makeAllReadOnlyExceptSubmit()
    > > {
    > > var f = document.getElementById("idOfYourForm");
    > > var inputs = f.getElementsByTagName("input");
    > > for(var i = 0; i < inputs.length; i++)
    > > if(inputs.type != "submit")
    > > inputs.readOnly = true;
    > > }

    >
    > Actually, you probably don't even need to check whether it's a submit
    > button or not - I don't think making a submit button read-only will
    > prevent it from being operational (techically it's ALWAYS read-only
    > since the user can't affect its value).
    >
    > Jeremy
    , Jun 22, 2006
    #4
  5. Jeremy Guest

    wrote:
    > not working!!! radio buttons are still available to select and change
    > value
    >


    At the end of the day, it's up to your user-agent to decide whether the
    read-only attribute will even be honored, and what effect it will have
    if it is.

    Do you have a URL or code snippet? It would be very helpful in
    determining why your code isn't working.

    Jeremy
    Jeremy, Jun 22, 2006
    #5
  6. James Black Guest

    wrote:
    > i have done the timing part, i hav setup a running clock which will
    > trigger the event @ XX amount of time but i m unable to make the radio
    > button disable or read only! remember submit button shld be available
    > to submit the form....


    How are you setting the clock?

    You may want to put an alert where it sets them to readonly, to verify
    that it is indeed getting there.

    For the timer, you may want to look at setTimeout, which is a
    javascript function.
    James Black, Jun 22, 2006
    #6
  7. Guest

    Sorry application is in offline mode, form is generated by php...

    i tried it on IE6 & 7, firefox, opera as well as on Safari its not
    working...

    i hav inserted an alert jst before and after your code... both the
    alert event is triggered but readonly is not working...



    Jeremy wrote:
    > wrote:
    > > not working!!! radio buttons are still available to select and change
    > > value
    > >

    >
    > At the end of the day, it's up to your user-agent to decide whether the
    > read-only attribute will even be honored, and what effect it will have
    > if it is.
    >
    > Do you have a URL or code snippet? It would be very helpful in
    > determining why your code isn't working.
    >
    > Jeremy
    , Jun 23, 2006
    #7
    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. Ghafran Abbas
    Replies:
    0
    Views:
    4,178
    Ghafran Abbas
    Oct 12, 2004
  2. John Salerno
    Replies:
    20
    Views:
    820
    John Salerno
    Aug 11, 2006
  3. Paul Oakfleet
    Replies:
    1
    Views:
    832
    Chris Riesbeck
    Sep 10, 2003
  4. Chuck
    Replies:
    0
    Views:
    246
    Chuck
    Nov 10, 2003
  5. Bart Van der Donck

    disable all elements from all forms except <textarea>'s

    Bart Van der Donck, Feb 1, 2005, in forum: Javascript
    Replies:
    3
    Views:
    111
    Stephen Chalmers
    Feb 1, 2005
Loading...

Share This Page