Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with a variable

    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.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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'
    }
    }

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by itsmadmax; 06-18-2004 at 06:42 PM.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's not working because of the highlighted parts of your code:

    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •