making checkbox non-editable

Discussion in 'Javascript' started by biswaranjan.rath, Apr 28, 2006.

  1. Hi,

    I've few checkboxes in different rows. After selecting appropriate
    values, the user should click a button. I wanted to convert those
    checkbox values to non-editable(or non-editable textboxes), so that
    user cannot change the value again after the needed functionality(this
    is in java script) completes. So my problem is that how should i
    manipulate the page through java script to set the field noneditable.

    Please suggest.

    Thanks,
    Biswaranjan
     
    biswaranjan.rath, Apr 28, 2006
    #1
    1. Advertising

  2. Also I can get the IDs of the checkboxes in java script function.

    Biswaranjan
     
    biswaranjan.rath, Apr 28, 2006
    #2
    1. Advertising

  3. biswaranjan.rath

    RobG Guest

    biswaranjan.rath said on 28/04/2006 3:54 PM AEST:
    > Hi,
    >
    > I've few checkboxes in different rows. After selecting appropriate
    > values, the user should click a button. I wanted to convert those
    > checkbox values to non-editable(or non-editable textboxes), so that
    > user cannot change the value again after the needed functionality(this
    > is in java script) completes. So my problem is that how should i
    > manipulate the page through java script to set the field noneditable.
    >
    > Please suggest.


    Set the disabled attribute of any unchecked radios to true, then the
    user can't select any other option.

    If scripting is disabled/not available, it won't work. If there's a
    reset button, the user can reset the form and clear the selections
    anyway. There are probably other ways around it, don't rely on it
    working for anything important.

    Play with this:

    <script type="text/javascript">

    function fixSelections(rGroup)
    {
    var i = rGroup.length;
    var j = i;
    var oneChecked = false;

    // Check that one has been selected
    while (j-- && !oneChecked){
    oneChecked = rGroup[j].checked;
    }

    // If one hasn't been selected, ask user to select one
    if (!oneChecked) {
    alert('Please check an option');
    return;
    }

    // If one has been selected, disable the rest
    while (i--){
    rGroup.disabled = !rGroup.checked;
    }
    }

    function enableRadios(rGroup)
    {
    var i = rGroup.length;
    while (i--){
    rGroup.disabled = false;
    }
    }

    </script>

    <form action=""><div>
    <input type="radio" name="r1">button 1<br>
    <input type="radio" name="r1">button 2<br>
    <input type="radio" name="r1">button 3<br>
    <input type="radio" name="r1">button 4<br>
    <input type="button" value="Fix selection"
    onclick="fixSelections(this.form.r1);"><br>
    <input type="reset" onclick="enableRadios(this.form.r1);">
    </div></form>



    --
    Rob
    Group FAQ: <URL:http://www.jibbering.com/FAQ>
     
    RobG, Apr 28, 2006
    #3
  4. Hi Rob,
    This is the solution for one set of radio buttons, still i'm in doubt
    that it'll affect the page. Anyway could you have any idea if it is the
    case of multiple dropdown lists, since in that case multiple names will
    be there. Also i want this to be reflected in the html page.

    Thanks,
    Biswaranjan
     
    biswaranjan.rath, Apr 28, 2006
    #4
  5. biswaranjan.rath

    Evertjan. Guest

    biswaranjan.rath wrote on 28 apr 2006 in comp.lang.javascript:

    > This is the solution for one set of radio buttons, still i'm in doubt
    > that it'll affect the page. Anyway could you have any idea if it is the
    > case of multiple dropdown lists, since in that case multiple names will
    > be there. Also i want this to be reflected in the html page.
    >


    Please quote what you are replying to.

    If you want to post a followup via groups.google.com, don't use the
    "Reply" link at the bottom of the article. Click on "show options" at the
    top of the article, then click on the "Reply" at the bottom of the article
    headers. <http://www.safalra.com/special/googlegroupsreply/>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Apr 28, 2006
    #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. Stephan Bour

    Making datagrid partially editable

    Stephan Bour, Jan 29, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,036
    Stephan Bour
    Jan 30, 2004
  2. =?Utf-8?B?cG11ZA==?=

    Making ONLY 2 columns editable in a datagrid

    =?Utf-8?B?cG11ZA==?=, Jan 10, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    3,378
    =?Utf-8?B?Q2hpbm1heQ==?=
    Jan 26, 2005
  3. Making editable datagrid.

    , Oct 13, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    154
  4. UJ
    Replies:
    1
    Views:
    583
    chandan
    Jan 15, 2007
  5. Prasad Peesapati

    Making a cell editable on clicking the cell

    Prasad Peesapati, Feb 3, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    130
    Prasad Peesapati
    Feb 3, 2005
Loading...

Share This Page