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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic Forms...

    Hello, I'm trying to create a script that will eventually give a price quote on a products.

    The thing I'm trying to do with Javascript is make a field appear if a specific option is selected in a dropdown box..

    Kinda like this:

    Print locations (1 or 2, dropdown box)

    [If 2 is selected, a new dropdown box will appear here]

    Anyone able to point me in the right direction? I'm a huge Javascript n00b.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Add an onchange handler to the dropdown and call a funciton in that function you need to do something like this:

    Code:
    var sel = document.forms[0].selectName1;
    if(sel.options[sel.selectedIndex].value == 1){
      document.getElementById("someDivId1").style.display = "block";
      document.getElementById("someDivId2").style.display = "none";
    }
    else{
      document.getElementById("someDivId2").style.display = "block";
      document.getElementById("someDivId1").style.display = "none";
    }
    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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