View Full Version : How can I use AJAX Dynamically

06-26-2006, 07:56 PM

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/dynamicindex1/chainedmenu/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/dynamicindex17/ajaxincludes.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:
<script type="text/javascript">
<script type="text/javascript">
</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:
<form name="listmenu0">
<table align="center">
<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')">
<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>
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.

06-27-2006, 04:13 AM


06-27-2006, 01:46 PM
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:
<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?
<script type="text/javascript">
/***Combo Menu Load Ajax snippet**/
function ajaxcombo(pathvariable, loadarea){
if (pathvariable !="" )
ajaxpage(pathvariable, loadarea)