Forum Moderators: coopster

Message Too Old, No Replies

echo html with javascript handler

Doing some AJAX stuff...

         

RIRedinPA

4:13 pm on Sep 7, 2007 (gmt 0)

10+ Year Member



I'm building a site that is a photo archive. The way it works is the photographers submit a series of photos for a log number. (5855-1, 5855-2, 5855-3, etc.)

A search returns the first image in a series (5855-1). Clicking on the image makes two hidden divs visible and initiates a AJAX script. The first div is just a screen to darken the background stuff, the second div gets populated with the results of the AJAX call, which is just a query to the db to get the number of images in the series and path to the thumbnails.

All works fine but on my php page that is called through the AJAX script I have this bit of code:

$table .= "</tr><tr valign='top'><td colspan='4' align='center'><p><a href='#' onClick=\"closeDivs();\">Close</a></td></tr></table>";

this is closing out the table that displays all the images. I am trying to drop in a javascript handler that would close the two divs and return the viewer to the initial view. However, when I click the "Close" link in Fire Fox, Error Console tells me that closeDivs is not defined.

On the page the user is on I do have the closeDiv() function at the top - here's the code:

<script language="javascript">

function closeDivs() {

if (browserType == "Firefox") {

//get screen div
screenDiv = document.getElementById("screen");
imageDiv = document.getElementById("imageFloat");

//get visibility state
screenDivView = screenDiv.style.visibility;
imageDivView = imageDiv.style.visibility;

//-->determine if it is on or off
if (screenDivView == "visible") {
screenDiv.style.visibility = "hidden";
}

//turn div on
if (imageDivView == "visible") {
imageDiv.style.visibility = "hidden";
}

</script>

I thought maybe it was looking for the JS on the PHP page that AJAX called but I dropped it (the closeDivs JS) on there and I still get the same errors.

Any ideas of how I can close these two divs?

d40sithui

4:27 pm on Sep 7, 2007 (gmt 0)

10+ Year Member



well, from your code, i see one thing wrong with it that could be the reason why its not working
you did not end the function closeDivs() and the if (browser=firefox) with a "}"

RIRedinPA

4:58 pm on Sep 7, 2007 (gmt 0)

10+ Year Member



doh, that was it, sometimes it just takes another set of eyes to look at something. Thanks!