Results 1 to 3 of 3

Thread: How can I use AJAX Dynamically

  1. #1
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default How can I use AJAX Dynamically

    Hi,

    The set-up:
    I'm going to use the chainedmenu script to give me a selection of data to display. The script is found at: http://www.dynamicdrive.com/dynamici...menu/index.htm
    And then display the data with an Ajax method. I found the script that I'm thinking of using here: http://www.dynamicdrive.com/dynamici...axincludes.htm

    The page will be password protected, so i'm running the page as .php

    The problem:
    In the body, the Ajax code is a hardcoded reference:
    Code:
    <script type="text/javascript">
    ajaxinclude("afile.htm")
    </script>
    or
    Code:
    <script type="text/javascript">
    ajaxinclude(rootdomain+"/includes/afile.htm")
    </script>
    but the reference will come from the chainedmenu script, so it has to be dynamic.

    The answer?
    Right now in another page using image data, I use a customized chainedmenu with the following in the body:
    Code:
    <form name="listmenu0">
      <table align="center">
        <tr>
          <td><select name="firstlevel" style="width:160px;"></select></td>
          <td><select name="secondlevel" style="width:160px;"></select></td>
          <td><select name="thirdlevel" style="width:160px;"></select></td>
          <td><input type="button" value="Go" onclick="goListGroup(document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel); firstimage()">
            <input type="button" value="Reset" onclick="resetListGroup('chainedmenu')">
        </tr>
      </table>
    </form>
    <div>
      <font size="2" face="Microsoft Sans Serif" ><center>
      <img id="pic" src="document.getElementById('pic').src" name="lidarimage" alt="" style="border: 1px solid ; width: 700px; height: 420px;" hspace="10" vspace="5" >
      <br>Use buttons to cycle through the available wavelengths for the day selected above.  Right-click to view as a larger image.</center></font>
    </div>
    and this works great. So, I think I have to use a DOM inside the Ajax call. But I haven't the foggiest idea of how to call this. Can someone fluent in modifying/implementing Ajax give me an idea? BTW, the displayed data will be wider than the page, so it will have to scroll.
    Thanks. I need some assistance again, please.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

  3. #3
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    But in these examples, the file to load is hardcoded into the script. In my case, the file name will be returned from the chainmenu function as a variable. I haven't tried to write this out yet, but, for instance, one of the examples from the reference you gave above (under using drop down menu to load links) is:
    Code:
    <script type="text/javascript">
    /***Combo Menu Load Ajax snippet**/
    function ajaxcombo(selectobjID, loadarea){
    var selectobj=document.getElementById? document.getElementById(selectobjID) : ""
    if (selectobj!="" && selectobj.options[selectobj.selectedIndex].value!="")
    ajaxpage(selectobj.options[selectobj.selectedIndex].value, loadarea)
    }
    </script>
    So, could I say this instead?
    Code:
    <script type="text/javascript">
    /***Combo Menu Load Ajax snippet**/
    function ajaxcombo(pathvariable, loadarea){
      if (pathvariable !="" )
      ajaxpage(pathvariable, loadarea)
    }
    </script>

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
  •