...

View Full Version : help with a variable



itsmadmax
06-18-2004, 02:53 PM
hi,

I want to fill the variable 'locatie' with some text depending on store

But of course it does not work :)

var locatie
function test1(){
if ( store == 02 || store == 03 ){
var locatie='C:'
}
else{
var locatie='Prxhou3/c'
}
}


help plz? :)
thnx.

Mr J
06-18-2004, 02:58 PM
You have to state or pass the value of store to the function

var store = 02

function test1(){
if ( store == 02 || store == 03 ){
var locatie='C:'
}
else{
var locatie='Prxhou3/c'
}
}

itsmadmax
06-18-2004, 05:40 PM
the store is filled by an other script and the value is kept as a cookie.
the thing is that for some reason locatie does not get filled.

Roy Sinclair
06-18-2004, 06:54 PM
It's not working because of the highlighted parts of your code:



var locatie
function test1(){
if ( store == 02 || store == 03 ){
var locatie='C:'
}
else{
var locatie='Prxhou3/c'
}
}


Those additional "var"s are causing the creation of local variables named "locatie" which are getting set instead of the global variable with the same name. Remove those highlighted "var" declarations and your code should start working.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum