Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4052156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:17:06+00:00 2026-05-20T14:17:06+00:00

Hi I have come up with a small design but im having one issue

  • 0

Hi I have come up with a small design but im having one issue with it, it uses jquery onclick if the user clicks the product it shows the product info in a right pain butmy problem is its showing the same information for each product, im coding it on local host so can’t link anyone (sorry). Here is my code:

    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/header/loader.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $(".buynow").click(function() {
            if($(".buynow").val() != 0) {
                alert("The product has now been added to the Shopping cart, click checkout to pay for your items, or close this window to continue shopping.");
            } 
        });

        // Put an animated GIF image insight of content
        $("#col2").empty().html('<img src="<?php bloginfo('stylesheet_directory'); ?>/header/loading.gif" /> Loading...');

        // load index page when the page loads
        $("#col2").load("<?php echo home_url('?page_id=2'); ?>  .entry-content");
        $("#col1 li span").click(function(){
        // load home page on click
            $("#col2").load("<?php echo home_url('?page_id=4&category=1&product_id='),wpsc_the_product_id(); ?>  .entry-content");
        });
        //$("#about").click(function(){
        // load about page on click
            //$("#response").load("about.html");
        //});
        //$("#contact").click(function(){
        // load contact form onclick
            //$("#response").load("contact.html");
        //});

        $(".product").hover(
          function() { $(this).children(".price").show(); },
          function() { $(this).children(".price").hide(); }
        ); 
    });
    </script>

    <ul id="col1">

    <?php while (wpsc_have_products()) :  wpsc_the_product(); ?>
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:17:06+00:00Added an answer on May 20, 2026 at 2:17 pm
    echo home_url('?page_id=4&category=1&product_id='),wpsc_the_product_id();
    

    maybe this comma id='),wpsc should be dot?

    Also you should do something like this:
    in html:

    <ul id="col1"><li><span id="product-<?php echo wpsc_the_product_id() ?>">Product <?php echo wpsc_the_product_id() ?></span></li></ul>
    

    in js:

    $("#col1 li span").click(function(){
            var productId = $(this).attr("id");// gets the id of span which contains product id
            productId = productId.split("-");
            productId = productId[1];// contains product id
            // load home page on click
                $("#col2").load("<?php echo home_url('?page_id=4&category=1&product_id=')?>"+ productId +" .entry-content");
            });
    

    Because you should declare id in loop for every product and not in js. If you declare it in js it will always be same, hardcoded. You can see that if you inspect you js when page loads. It will always call first product id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come across the following jQuery code but could not understand it. What
I have come up with a small issue in my application. I changed the
I have a site built on codeigniter but I have come accross a small
I'm trying to write a small application and have come across a compile time
Hii , I have a small php form. I need it to come in
I have come across a situation (which I think is weird but is possibly
I have been using automapper pretty successfully lately but i have come across a
I have been having an issue with Visual Studio 2010 that is driving me
Design -- in a perfect world I have one abstract base class A with
So I am writing a small PHP framework for fun, and I have come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.