Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    radio buttons not working properly

    if( cols[5] != 'M' ) {
    document.getElementById('Manager').checked=false;
    document.getElementById('Trainer').checked=true;
    alert("cols[5]: "+cols[5]);
    }
    else if( cols[5] != 'T' ) {
    document.getElementById('Trainer').checked=false;
    document.getElementById('Manager').checked=true;
    alert("cols[5]: "+cols[5]);

    In the above code I get 'M' and 'T' values from databse and the Manager radio Button works fine based on the value 'M'. But never Tariner Radio is checked even the value from database is 'T' and the alert shows it too.

    Note: In the form I used attribute name="who" for both the Radio Buttons
    Can any one help me? thanks

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    In the above code I get 'M' and 'T' values from databse and the Manager radio Button works fine based on the value 'M'. But never Tariner Radio is checked even the value from database is 'T' and the alert shows it too.
    How do you get the value from Database? Are you getting the right values?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Feb 2009
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yes I get either 'M' OR 'T' depending on value in DataBase.
    alert("cols[5[] : " cols[5[]); displays it. but somehow the document.getElementBYId('Trainer').checked=true; not working.

    codingforumsun.


    below is the some more code from webpage. I used name=Who for both the radio buttons.


    <input type="radio" value=T name=Who id="Trainer">Trainer?<input type=radio value=M name=Who id="Manager">Manager?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    document.getElementById('Manager').checked=false;
    document.getElementById('Trainer').checked=true;
    I think you need to use the statement having checked=true, since both of them have the same name.
    Code:
    document.getElementById('Trainer').checked=true;
    btw, properly enclose the attribute values inside double quotes, to make your markup valid.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Feb 2009
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts
    No luck I tried that.

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    below is the some more code from webpage. I used name=Who for both the radio buttons.
    <input type="radio" value=T name=Who id="Trainer">Trainer?<input type=radio value=M name=Who id="Manager">Manager?
    Could you post your entire form and some more javascript, so that we can try to execute at our end?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •