Passing a variable to javascript via a link
My website has a javascript variable (addselectedsubdivision) that loads a neighborhood name from a box on the left to a box on the right. I was hoping I could build a link and then us PHP to add the subdivision letter, neighborhood, and city so that when you click on the link it goes right to this page and loads the neighborhood name in the box on the right. 开发者_JAVA百科However, I can't get the variable to pass to the new page. Any suggestions?
Website: http://www.mlsfinder.com/va_rein/jonmcachran/index.cfm?primarySearchType=sold&searchType=subdivision&so=a&domain=www.jonsellsvb.com&subdivision_string=p
Example link:
<a href="http://www.mlsfinder.com/va_rein/jonmcachran/index.cfm?primarySearchType=sold&searchType=subdivision&so=a&domain=www.jonsellsvb.com&subdivision_string=$firstletter" onLoad="addselectedsubdivision($neighborhood||$city);" target="_blank">
What is the onLoad
attribute meant to do?
In index.cfm
you will need to have coldfusion code that will output a javascript statement based on the query parameters.
So when the serverside sees that it has the arguuments $neighborhood
and $city
then it will output
...
addselectedsubdivision("cityfromquerystring");
...
This code will have to be contained in an window.onload = function() {...}
or equivalent block in order to only be executed after the page has loaded.
精彩评论