Forum Moderators: open

Message Too Old, No Replies

Map with Database

map database using javascript ajax and spry

         

HealthisWealth

6:38 pm on Apr 19, 2010 (gmt 0)

10+ Year Member



I am creating a section of my company's webpage that will allow viewers to click on their state and the output will show what stores in that state carry which of our companies products. All the information is in a database which is available on my sites php myadmin.

I have been creating this as a modification of Adobes tutorial titled "Building a website with Web Premium CS4" using javascript, ajax, and spry. Everything works to the point where when I look at my page, the map shows and the entire database prints out showing the following columns "Store" " St_address" "City" "State" "Zip" "Product" .. Great.

But then, when I click on the state, Alabama (AL) for example, I receive the error, "AL" is undefined. The same error holds true for each state, replace state abbreviation for AL.

I am defining the following function in the Head tags,

var dsMap = new Spry.Data.XMLDataSet("CORRECT URL", "data/row", {sortOnLoad: "state", sortOrderOnLoad: "ascending"});
var showdetail = false;
function filterMap(state) {
showdetail = true;
dsMap.setCurrentRow(state);
Spry.Data.updateAllRegions();
}

then I have the states outlined using Photoshop CS4's hotspot tool, and call the script in the link field with the following,

javascript:filterMap(AL)

The appropriate state abbreviation in place for each state. The same state abbrevation is used in the the Database under the "state" field column.

I have been working on this for a while, and cant figure out how to properly define the state abbreviation. Any help is appreciated.

LifeinAsia

6:51 pm on Apr 19, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Try something like:
javascript:filterMap("AL")

And welcome to WebmasterWorld [webmasterworld.com]!

HealthisWealth

8:34 pm on Apr 19, 2010 (gmt 0)

10+ Year Member



I tried that, and when I click on the state, nothing happens.

LifeinAsia

9:24 pm on Apr 19, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Something happens- you just need to add some debugging and checking to see exactly what.

Do you know what the underlying code is for the dsMap.setCurrentRow(state) call? I've never used Spry, so I can't help you with anything related to that. But my guess is that something called setCurrentRow would be looking for a row number, not a character string.

HealthisWealth

7:11 pm on Apr 20, 2010 (gmt 0)

10+ Year Member



Thanks for the help so far. This is my first time working with Spry, and by far my most ambitious WebDev project to date.

dsMap is a spry DataSet and the setCurrentRow is based on the spry dataset. In the Adobe model I am using, the setCurrentRow IS looking for a row number. i though maybe I could switch it to a string. Then I thought maybe I could add a table that was a list of numbered states to my database so that each state would be numbered, and that might work, but I couldn't figure out the proper way to link the three tables together with spry.

I do not need to use spry on this. Is there another way that you recommend that I could have either a form with a drop down list or map that would allow the output to be a list of stores. Theoretically each state could have an infinite number of stores listed with address and phone number queried by state and product (i.e. all stores in Pennsylvania that sell our Chicken Nuggets)