<% strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=your_database_location.mdb" DIM objConn DIM tipRec DIM today DIM tip DIM id 'type is either daily or random tiptype = request("type") 'setup database connections and recordsets Set objConn = Server.CreateObject ("ADODB.Connection") Set tipRec = Server.CreateObject("ADODB.Recordset") objConn.Open strConnect 'generate random number between 1 and 366 'Currently there are only 366 tips in the database 'You could get the size from the database and then generate a random number on this randomize id =int(rnd * 366) 'Decide which SQL Query to use if tiptype = "daily" then sqlText = "SELECT * FROM tips WHERE showdate = #" & CDate(Date) & "#" elseif tiptype = "random" then sqlText = "SELECT * FROM tips WHERE tipid = "& id &";" end if 'execute query Set tipRec = objConn.execute(sqlText) 'get the first record returned tipRec.MoveFirst 'tip2 is a temporary string used to hold tip tip2 = tipRec("tip") 'Need to replace certain characters for javascript to output 'You should check for other problematic string literals also. tip = Replace(tip2, "'", "\'") 'Close our database connections Set tipRec = nothing objConn.close %> function ShowTracker() { var tmpStr; tmpStr = ('<%=tip%>'); document.write(tmpStr); }