1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need yours help about javaScript in ASP (1)

Discussion in 'C#' started by john_vn, Oct 27, 2005.

  1. #1
    This code cannot run
    CODE JavaScript:

    var cookieKey = null;
    var cookieItem = null;
    for (cookieKey in Request.Cookies)
    {
    if (Request.Cookies(cookieKey).HasKeys)
    for (cookieItem in Request.Cookies(cookieKey))
    Response.Write(Request.Cookies(cookieKey)(cookieItem));
    else
    Response.Write(Request.Cookies(cookieKey));
    }

    while this code runned :
    Code VBScript:
    Dim cookieKey;
    Dim cookieItem;
    for each (cookieKey) in Request.Cookies
    if (Request.Cookies(cookieKey).HasKeys then
    for each cookieItemin Request.Cookies(cookieKey)
    Response.Write(Request.Cookies(cookieKey)(cookieItem))
    next
    else
    Response.Write(Request.Cookies(cookieKey))
    end if
    next

    How can i repair this code in JavaScript to run as same as VBScript????
    Thanks
    John
     
    john_vn, Oct 27, 2005 IP
  2. factorysealed

    factorysealed Well-Known Member

    Messages:
    120
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Try this:

    <%
    Dim cookieKey
    Dim cookieItem
    for each cookieKey in Request.Cookies
    if Request.Cookies(cookieKey).HasKeys then
    for each cookieItemin in Request.Cookies(cookieKey)
    Response.Write(Request.Cookies(cookieKey)(cookieItem))
    next
    else
    Response.Write(Request.Cookies(cookieKey))
    end if
    next
    %>
     
    factorysealed, Oct 27, 2005 IP
  3. john_vn

    john_vn Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh, Sorry i type wrong.
    My VBscript is correct and run well.
    But my JavaScript code has a problem, i cannot run it.
    I dont know what error it has.???
    Please help me to debug my JavaScript code.
     
    john_vn, Oct 27, 2005 IP
  4. factorysealed

    factorysealed Well-Known Member

    Messages:
    120
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    135
    #4
    hmm... i'm not to good with Javascript...

    There is a typo in your code though:
    You have:
    " for (cookieKey in Resquest.Cookies) "

    It should be:
    " for (cookieKey in Request.Cookies) "

    You've got an extra "s" in "Request"

    Hope that works out for you.
     
    factorysealed, Oct 27, 2005 IP
  5. john_vn

    john_vn Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Oh,it just another my type wrong there.
    So,i change it.
    And anybody can help me?
     
    john_vn, Oct 27, 2005 IP
  6. omgitapro

    omgitapro Banned

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    did it work for <%
    Dim cookieKey
    Dim cookieItem
    for each cookieKey in Request.Cookies
    if Request.Cookies(cookieKey).HasKeys then
    for each cookieItemin in Request.Cookies(cookieKey)
    Response.Write(Request.Cookies(cookieKey)(cookieItem))
    next
    else
    Response.Write(Request.Cookies(cookieKey))
    end if
    next
    %>
    ?? if not try google it for the problem
     
    omgitapro, Oct 27, 2005 IP