Welcome, Guest
  • Author Topic: Need help checking variable loaded from querystring  (Read 1394 times)

    Adam

    • Server what's that
    • *
    • Posts: 34
      • View Profile
      • Email
    I'm loading a variable from a querystring into my flash movie. Using ASP I create 2 kinds of embed and object tags in the html that contain either:

    "movname.swf?ikey=1"    or     "movname.swf?gid=1"

    in flash (frame 1, main timeline) I try to detect the variable like this:

    if (ikey=="") {
      do this...
    }else{
      do this...
    }

    My problem is that when I send the gid=1 parameter the if statement does not pick up that ikey should equal "". I tried trace to see if it's "undefined" but that didn't work. Does anyone know what I'm doing wrong here?

    Thanks,
    Adam

    bpat1434

    • Moderator
    • Senior Programmer
    • *****
    • Posts: 419
    • Never Miss An Opportunity To Be Great.
      • MSN Messenger - bpat1434@hotmail.com
      • AOL Instant Messenger - bpat1434
      • Yahoo Instant Messenger - bpat1434
      • View Profile
      • bPatterson
    Re:Need help checking variable loaded from querystring
    « Reply #1 on: 05/11/04, 20:53 »
    why not change it to say:

    [script]
    if(ikey=="1"){
       dothis.....
    }else{
       dothis.....
    }[/script]

    That should work since it's looking for ikey to equal 1, and not ikey equal to "".

    If not, I'm just offering help.

    ~Brett

    Adam

    • Server what's that
    • *
    • Posts: 34
      • View Profile
      • Email
    Re:Need help checking variable loaded from querystring
    « Reply #2 on: 05/12/04, 08:49 »
    Yes, I can certainly set it up to always send a parameter with a value but sometimes decisions like that can come back to haunt me. I'll go that route if a better solution doesn't present itself but I would still like to know how to address the issue properly because it's bound to come up again.

    bpat1434

    • Moderator
    • Senior Programmer
    • *****
    • Posts: 419
    • Never Miss An Opportunity To Be Great.
      • MSN Messenger - bpat1434@hotmail.com
      • AOL Instant Messenger - bpat1434
      • Yahoo Instant Messenger - bpat1434
      • View Profile
      • bPatterson
    Re:Need help checking variable loaded from querystring
    « Reply #3 on: 05/12/04, 11:21 »
    Well, if you tried to detect if it was undefined, did you try to trace the variable?  See what the ikey value really is when you send igid?  It could be "NaN".

    As for the proper solution, I don't see how this wasn't a proper solution, but I'm sure there is another way to get what you want.  You could also do this:

    [script]if((ikey=="") || (ikey=="NaN") || (ikey=="undefined")){
       dothis....
    }else{
       dothis....
    }[/script]

    That way you cover all of your base, if ikey is undefined, NaN, or blank, your if statement will catch it.  the "||" act as an OR statement (if this or this or this are true).  If you knew that, kool, if not, just tryin to help explain what the code means.

    Hope that helps some.

    ~Brett

    Adam

    • Server what's that
    • *
    • Posts: 34
      • View Profile
      • Email
    Re:Need help checking variable loaded from querystring
    « Reply #4 on: 05/12/04, 11:29 »
    Thanks for the reply. Yes, I tried tracing it but it came back looking like "". It could also be a null character. I didn't get either NaN or undefined. Either, your original work around will certainly do the job, so I'm not going to beat a dead horse. :)

    Thanks,
    Adam

    bpat1434

    • Moderator
    • Senior Programmer
    • *****
    • Posts: 419
    • Never Miss An Opportunity To Be Great.
      • MSN Messenger - bpat1434@hotmail.com
      • AOL Instant Messenger - bpat1434
      • Yahoo Instant Messenger - bpat1434
      • View Profile
      • bPatterson
    Re:Need help checking variable loaded from querystring
    « Reply #5 on: 05/12/04, 11:35 »
    Ok.  However you want to go after it.

    ~Brett