Results 1 to 2 of 2

Thread: dynamic drive ajax tabs - dropdown

  1. #1
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default dynamic drive ajax tabs - dropdown

    Script Name: Ajax Tabs Content Script (v 2.2)
    Script URL: http://www.dynamicdrive.com/dynamici...axtabscontent/

    Code:
    <!--Load "canada.htm" into the the Ajax Tabs Content Container -->
    <a href="javascript:countries.loadjaxpage('canada.htm')">Load New Page</a>
    I want do load a page using a drop down menu, i've tried this, but it doesnt seem to work! anybody got any ideas? thanks

    Code:
    <option value="something" onChange="javascript:countries.loadjaxpage('canada.htm')">Something</option>

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I assume you're trying to run the function loadajaxpage() inside a SELECT drop down menu? What you have won't work since the JavaScript syntax is incorrect. For example, onChange can't be added inside the OPTION element, it has no effect. Here's an example that should work:

    Code:
    <form id="aform">
    <select id="mymenu" size="1">
    <option value="nothing">Select a page</option>
    <option value="canada.htm">Canada</option>
    <option value="china.htm">China</option>
    <option value="usa.htm">USA</option>
    </select>
    </form>
    
    <script type="text/javascript">
    
    var selectmenu=document.getElementById("mymenu")
    selectmenu.onchange=function(){ //run some code when "onchange" event fires
     var chosenoption=this.options[this.selectedIndex] //this refers to "selectmenu"
     if (chosenoption.value!="nothing"){
      countries.loadajaxpage(chosenoption.value)
     }
    }
    
    </script>
    You may want to read up on how to manipulate SELECT menus in JavaScript.
    DD Admin

Bookmarks

Posting Permissions

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