Action based on radio button selection...

Discussion in 'HTML & Website Design' started by toughguy, Feb 6, 2006.

  1. #1
    Hi All,
    I would like to know the procedure to do the following:

    I have to give the user an option to select whether he wants to give a particular date or a date range. (I used two radio buttons only one can be selected at a time) I have two date inputs which are deactivated by default. If user select only one date then I need to activate one date input and if he selects date range then i have to activate 2 date inputs.

    Can anybuddy help me out to make this done using basic HTML or JAvASCRIPT.

    Thanks a million for your help..

    Regards,
     
    toughguy, Feb 6, 2006 IP
  2. juniorcj

    juniorcj Guest

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You would need javascript for this as its a dynamic form, reacting to user choices.

    Search google for "dynamic javascript form" - there's a ton of stuff there.
     
    juniorcj, Feb 8, 2006 IP
  3. alimkb

    alimkb Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    You can use this simple code .

    <script language="javascript">
    function DateOne()
    {
    myForm.T1.readOnly = false ;
    myForm.T2.readOnly = true ;
    myForm.T3.readOnly = true ;
    }
    function DateTwo()
    {
    myForm.T1.readOnly = true ;
    myForm.T2.readOnly = false ;
    myForm.T3.readOnly = false ;
    }
    </script>

    please see attached file .
     

    Attached Files:

    alimkb, Feb 8, 2006 IP
  4. arnek

    arnek Active Member

    Messages:
    134
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    radio buttons have always been quite a hard element in HTML to work with(or just sometimes).

    I had alot of problems with radio buttons, with validating a form, as you cannot just get the value of a set of radio buttons, you had to loop through all the raiod button elements and work in such a way and check each radio buttons' value...

    But anyways, hope alimkb's post will help ya
     
    arnek, Feb 12, 2006 IP