SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Help: How to hide form data?

    Hi all, I'm trying to use the following Javascript photo viewer on my website: http://www.web1marketing.com/photoviewer/example.htm

    Since I use a GET method to pick up an ID passed from an other page on my website, the url ends up like http://www.site.com/product.php?product_id=1 It works fine there.

    However, when I click on any of the index links or the Next arrow. It then gets stuck (photos are not showing) because the url changes to http://www.site.com/product.php?photo=2
    This url rule is defined in the photo_viewer.js link is below:
    http://www.web1marketing.com/photovi...hoto_viewer.js

    I've been trying to modifying photo_viewer.js but can't get it work. Any ideas?

    Thanks in advance!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Koan:
    Do not try to carry the querystring from one page to the next.
    Instead, save it to a cookie so that when the querystring is lost, you are not.

    Haiku:
    Querystring gets lost?
    Save it to a cookie file,
    You are lost no more.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi paul, I'm i bit confused. On one page, I have all the products listed with brief introduction. When a user clicks on the title of one product, the details of the product is displayed. Isn't it quite common? Thanks.

    Btw, I've just managed to log on my original account

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    When you have control over the scripting environment then you can make use of custom querystring.
    Without such control, other avenues present themself.

    use the querystring code from http://adamv.com/dev/javascript/querystring
    Use the cookie code from http://www.quirksmode.org/js/cookies.html


    Code javascript:
    var qs = new Querystring();
    var product_id = qs.get("product_id");
    // Parse the product_id when available and save it to a cookie.
    if (product_id) {
        createCookie('product_id', product_id, 1);
    } else {
        // Otherwise get it from the cookie.
        product_id = getCookie('product_id');
    }
    if (!product_id) {
        // no querystring OR cookie exists
        return;
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Paul, I have added the above code on my listing page, but it's still not working ... It looks like the id is not stored in the cookie properly? Sorry I'm just a beginner to this area.
    http://yourate.co.nz/viewer/listing.php
    You can view the code at http://yourate.co.nz/viewer/

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    There are two problems that you're facing.
    The code is currently on the listing.php page when it should be on the listing_details.php page instead, and you don't appear to have the libraries for handing cookies and querystrings included anywhere on the page.

    After you have the libraries included and this simple solution working, later on we can work on improving the gallery code by having that use the same querystring library, then further extend that gallery code so that the cookies won't be required at all.

    Right now though, it'll take more effort than it's worth to try and force the gallery code to do what you need, and the end result won't be anywhere near as useful.

    That's the overall plan of things. Even if you just achieve the first step though, that will be a very usable for you right there.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    There are two problems that you're facing.
    The code is currently on the listing.php page when it should be on the listing_details.php page instead, and you don't appear to have the libraries for handing cookies and querystrings included anywhere on the page.
    Hi Paul, would this be a right start?
    http://yourate.co.nz/viewer/listing_details.php
    I have never used cookies before so more assistance would be appreciated.


Bookmarks

Posting Permissions

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