This is a migrated thread and some comments may be shown as answers.

variable outside of a function

0 Answers 36 Views
Forum suggestions
This is a migrated thread and some comments may be shown as answers.
rahi
Top achievements
Rank 1
rahi asked on 10 May 2011, 09:59 AM
Hi,

I am having a little trouble displaying a variable that's created in a function. I am using an onclick to pass a value from 1-4 depending on the link clicked. I have made the function check to see if the value is 1-4 then created 4 variations of the same variable. So:
if(a=1){
para='text';
}
if(a=2){
para='text';
}
etc

I want to be able to output the value of para anywhere I choose in my html. At the moment I am trying to output the variable in a div using document.write. I have set the variable para outside of the function to make it global, but it still does not work. I know the variable is working inside the function as i have tested it with alert to make sure I'm getting the right value.

any help on this would be great :)

Cheers _____________________ [url=http://www.freeezinearticles.com/2010/11/12/sightline-payments-llc-focuses-on-zeros-to-lead-the-industry/]Sightline Payments Kirk Sanford[/url]
[url=http://www.pokerspelaren.se/]poker[/url]

No answers yet. Maybe you can help?

Tags
Forum suggestions
Asked by
rahi
Top achievements
Rank 1
Share this question
or