Skip to main content
Participant
June 4, 2008
Question

If Else within Form

  • June 4, 2008
  • 3 replies
  • 527 views
I am creating a form to add employees into an employee database. In the form I have 2 radio buttons displaying Office1 and Office2. If the user selects Office 1, then a droplist should appear displaying Departments for Office 1...the same goes for Office2 and its departments. How do I create this if else statement within a form before submission? Do I use Javascript? Thanks for the help..
    This topic has been closed for replies.

    3 replies

    Participant
    June 5, 2008
    As always, it depends.

    You don't need Javascript, unless you want a page reload without someone clicking submit. If you preload everything to the web browser before with Javascript, you don't need AJAX. If you want in-line updates without reloading the entire page and pre-populating Javascript, you need AJAX.

    So it can be done any which way...the way you want the user to interact with the site is what determines the route. Chances are, Javascript is a necessity.

    AJAX in this case is often the most user friendly, though it should degrade gracefully (work without Javascript). Tools like JQuery make it easy and fun, but it does get funky thinking the degradable way.
    Inspiring
    June 4, 2008
    The concept is similar to Related Selects. (seems to be the theme of the day). Here's how I once did it. http://www.pathcom.com/~bracuk/code/RelatedSelects.htm .
    Inspiring
    June 4, 2008
    Do you want to use the if else to show your drop down list? if so, yes you need to use javascript.
    Tom WaAuthor
    Participant
    June 4, 2008
    Yes.. what I want is...If user selects Office1 show DepartmentList1. Else If user selects Office 2 show DepartmentList2.