Thanks. I am using coldfusion. I found a way to read the text file and assign the contents of that text file into a coldfusion variable. I then can pass that variable to the javascript. This looks like it is working.
So I am passing a state name through as a variable from a link. Then I have to take the value of the state name and compare it with the value of the coldfusion variable I made for the text file. This works, but it is going to be one really really long if statement. Is there a better way to do this?
Example:
ColdFusion to Read a File (oklahoma and texas):
Code:
<cflock name="text_file_cities" type="readonly" timeout="30">
<cffile action="read"
file="c:/filelocation/OK.txt"
variable="Oklahoma"
charset="utf-8">
</cflock>
<cflock name="text_file_cities" type="readonly" timeout="30">
<cffile action="read"
file="c:/filelocation/TX.txt"
variable="Texas"
charset="utf-8">
</cflock>
ColdFusion variable to Javascript variable:
Code:
<cfoutput>
var #toScript(Oklahoma, "Oklahoma")#;
</cfoutput>
Javascript code snippet:
Code:
function showdiv(state) {
document.getElementById('cities_popup_container').style.visibility = 'visible';
document.getElementById('state_name').innerHTML=state;
if(state =='Oklahoma')
document.getElementById('cities_list').innerHTML=Oklahoma
if(state =='Texas')
document.getElementById('cities_list').innerHTML=Texas;
and so on.....
and so on.....
}
Link to page with javascript :
Code:
javascript:showdiv('Oklahoma')
javascript:showdiv('Texas')
And so on for most of the 50 states
Are the If Statements the best way to handle this?
Thanks!!
Stephanie
Last edited by angele803; 03-11-2008 at 12:44 PM..
|