VBscript boolean function causes Javscript to bomb

Discussion in 'JavaScript and AJAX' started by calgarychinese, Aug 25, 2008.

  1. calgarychinese

    calgarychinese Banned

    Joined:
    Aug 25, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi there

    I have a server-side VB that runs at the beginning of the asp page, and it returns a result set, call it loResultSet.

    In the client side javscript, I was trying to check to see if this result set is nothing or not.

    if (<%=(loResultSet is nothing)%>)

    {

    // javscript code

    }



    However it bombs because that (loResultSet is nothing) returns "True", as opposed to "true", and Javascript doesn't recognize True.

    I know this is a dumb question, but how would you fix this, and I mean, not in a hack way, such as

    if (%=(loResultSet is nothing)%>.toString().toLowerCase())



    Many thanks appreciated.

    CC
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Code:
    if (eval("<%=(loResultSet is nothing)%>%>".toString().toLowerCase()))
    
    {
    
    // javscript code
    
    }
    
    Try this!
     
  3. calgarychinese

    calgarychinese Banned

    Joined:
    Aug 25, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi pradeep, however how is your solution different than mine except for the eval part you added? (I was actually hoping there would be some standard function to do that, for us to manipulate the results like this looks a little counter-productive - I guess that's the diff between javascript and vbscript...)

    Thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice