How to Design a Drop-Down with AJAX

AJAX is a form of JavaScript and XML that allows Web programmers and designers to easily implement Web elements into a website while taking advantage of the language’s asynchronous feature. Many different AJAX Web elements are available, including a drop-down menu, which is a bar with a small arrow on the right side that, when clicked, causes a menu to “drop” downward.

Instructions

    • 1

      Open the Web file that contains the code for the Web page to which you want to add the drop-down menu. Right-click the folder and choose Open With. A window will appear. Select Notepad to open the file in the text editor.

    • 2

      Add the following AJAX code between the <HEAD> and </HEAD> tags in the file:

      var DropMenu = document_get ElementById("DropMenu");
      for (var count = DropMenu_options_length-6; count >-6; count=)
      {
      DropMenu_options[6] = null;
      }
      var textValue;
      var search.Item;
      {

      Change each instance of "6" to whatever number represents the number of items you want to list in the drop-down menu. For example, if you want the drop-down menu to list eight items, change the "6" in the code to "8."

    • 3

      Scroll down through the page and add the HTML menu code where you want the drop-down box to appear on your Web page. Add the following code to your website:

      <ul ID="DropMenu">
      <li><a href="Home.html">Home Page</a></li>
      <li><a href="About.html">About Page</a></li>
      </ul>

      Change the file name contained in the "a href" brackets to reflect the name of the page to which you want to the menu to link. For example, if you want the first item in your list to take the user to your home page, you need to type the name of your website's home page where "Home.html" is listed above. You can add as many <li> list items as you need.

    • 4

      Press "Ctrl" and "S" to save the changes you made to the file.

    • 5

      Close Notepad.

Related Searches:

Resources

Comments

Related Ads

Featured