Show/Hid div

Discussion in 'JavaScript' started by Fracisc, Feb 27, 2009.

  1. #1
    I have 3 radio buttons.

    1. - when checked, should hide both divs
    2. - when checked, should display div 2 (only)
    3. - when checked, should display div 3 (only)

    I used
    function abox(state)
    {
    document.getElementById('abox').style.display = state;
    }
    
    Code (markup):
    But when using this, the prompter do not want to move to the 2nd text box, when I click into it, it goes to the first textbox. It is something like on click go to the first item.
     
    Fracisc, Feb 27, 2009 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    set id property of text box input:

    <input type="text" id="abc" ..............>

    to set focus use
    document.getElementById("abc").focus();
     
    Vooler, Feb 28, 2009 IP
  3. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,670
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #3
    Thanks, I have already managed to do the task. :)
     
    Fracisc, Feb 28, 2009 IP