1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to create this Javascript form?

Discussion in 'JavaScript' started by Ladan Lashkari, Jan 19, 2007.

  1. #1
    I want to create a form on my website that has 3 radio buttons and when someone clicks on each radio button, a different text paragraph appears.

    I know I need to use <div> tag, but I'm not sure how exactly.

    I tried to find such a script by searching in Google but they all were just ordinary web forms.

    So do you know how I can create such a form using Javascript?

    Thanks.
     
    Ladan Lashkari, Jan 19, 2007 IP
  2. MattD

    MattD Peon

    Messages:
    161
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I cant give you the code off of the top of my head, but hopefully this will point you in the right direction for more searching.

    Basically yes you can use divs to do this - put them in your HTML with all of the text in, but give each a different id and use CSS to make sure each div is set to invisible.

    In javascript you can make a small function that will use CSS to make an element visible or invisible - you'll need to use document.getElementById(), then once you have got the element you can change its CSS to invisible, e.g. element.style.display = "none" to hide it etc.

    Then you need to add an onclick bit of javascript to each of your radio buttons to call the javascript function to show/hide the divs you want.

    Hope that helps - if you need more help say so.
     
    MattD, Jan 20, 2007 IP
    Ladan Lashkari likes this.
  3. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #3
    I agree with Matt - yes that will work. Based on the instruction that he gave, you will need to position them at the same place.
     
    datropics, Jan 20, 2007 IP
  4. Ladan Lashkari

    Ladan Lashkari Active Member

    Messages:
    136
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Thank you very much Matt! That was awesome advice. I think I can do it easily now. :)
     
    Ladan Lashkari, Jan 20, 2007 IP
  5. MattD

    MattD Peon

    Messages:
    161
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey no problem - I could dig out some working javascript if you need it.
     
    MattD, Jan 20, 2007 IP