www.webdeveloper.com
Results 1 to 4 of 4

Thread: Links from cookies?

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Question Links from cookies?

    Ok, so I have these 2 cookies: 'orderno' and 'gtotal', and I need to post thier values into a <img> tag.

    i need to have

    Code:
    <img src="https://www.twistoflemon.co.za/report?orderNumber=orderno&orderValue=gtotal">
    the values in bold need to be loaded from my cookies.
    can this be done?

  2. #2
    Join Date
    Nov 2007
    Posts
    431
    Can this be done, yes.

    If you must use Javascript:
    step 1 - find yourself a javascript cookies library you are happy with.
    step 2 - use the "getCookieValue(cookiekey)" function (it will be named differently) from the library like this:
    Code:
    var orderNumber = getCookieValue('orderno');
    var orderValue = getCookieValue('gtotal');
    Hopefully you can place an ID onto that image, so that the image is like:
    Code:
    <img id='Booyah' src="https://www.twistoflemon.co.za/report?orderNumber=orderno&orderValue=gtotal">
    Then you update the image's source, like this:
    Code:
    document.getElementById('Booyah').src = 'https://www.twistoflemon.co.za/report?orderNumber=' + orderNumber + '&orderValue=' + orderValue ;

  3. #3
    Join Date
    Feb 2012
    Posts
    218
    If your page is a PHP is even easier.
    HTML Code:
    <img src="https://www.twistoflemon.co.za/report?orderNumber=<?php echo $_COOKIE['orderno']?>&orderValue=<?php echo $_COOKIE['gtotal']?>">

  4. #4
    Join Date
    Nov 2007
    Posts
    431
    Server side, very simple.
    JavaScript, requires some cookie functions.

    Classic ASP
    Code:
    <img src="https://www.twistoflemon.co.za/report?orderNumber=<&#37;=Request.Cookies("orderno")%>&orderValue=<%=Request.Cookies("gtotal")%>">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles