Jump to content

SQL Script to work with Javascript: Window SetInterval & Location


dimas2
 Share

Recommended Posts

Hi, I'm having hard time with some functions I want to set up but I'm NOT really good with scripts, so I appreciate any help.I'm including three pages in an ASP file. One is the HEADER, the MAIN page to the left is a flash catalog, every time I turn pages the address bar changes showing the extension for the page displaying at that time.Using Javascript, the page to the RIGHT shows products related with the actual page in the catalog.So far it works as the way I want to. In the Javascript I'm using 4 different products/images for now, but if I need to add 4000? it's going to be a VERY long page and a nightmare!What I need now is have it work as it is, but instead using variables from javascript, adapt a Script to work with SQL database. I need to show: Image, Name, PRICE and include a link to it's own page.I sat up a testing database with two tables:CATALOGS: cat_ID, mainCat, subCcat, sortVal, description and url.CATPRODUCTS: CatP_ID, CatID, PID, Description, Image, PageN, Price and SortRight now It works well, of course without the javascript, I can't make it work as I need it.Here is the code for SQL:<%PageN = TRIM( Request("PageN"))Set Con = Server.CreateObject( "ADODB.Connection" )Con.Open Application("connstr")'Get the Product Information to the rightsqlString = "SELECT * FROM CatProducts WHERE PageN = " & TRIM( Request("PageN")) & " Order by Sort "Set RS = Server.CreateObject( "ADODB.Recordset" )RS.ActiveConnection = ConRS.Open sqlStringFor I = 1 to 500%>CatID = <%=RS( "CatID")%><Br>PID = <%=RS( "PID")%><Br>Imag = <%=RS( "Imag")%><Br>Description = <%=RS( "Description")%><Br>Price = <%=RS( "Price")%><Br><Br><br><% RS.MoveNextWENDRS.Close%>-------------------------And the java script:<script language="javascript" type="text/javascript">var int=window.setInterval(setLocationHref, 500);function setLocationHref(){ var hashVal = location.hash; if (hashVal=="#/1/") { document.getElementById("message").innerHTML="<img src=MainPage1.gif></img>"; } else if (hashVal=="#/2/") { document.getElementById("message").innerHTML="<img src=MainPage2.gif></img>"; } else if (hashVal=="#/4/") { document.getElementById("message").innerHTML="<img src=MainPage2.gif></img>"; } else if (hashVal=="#/6/") { document.getElementById("message").innerHTML="<img src=MainPage2.gif></img>"; } else { document.getElementById("message").innerHTML="<img src=MainPage1.gif></img>"; } }function setLocation(href){ location.href = document.getElementById(href).value;}</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...