Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2010
    Posts
    19
    Plugin Contributions
    0

    Default How to add javascript? OMG?

    http://www.tutorialtastic.co.uk/tuto...ith_javascript

    Hi, I am trying to add this javascript code. The idea is to hide product attributes on the product listing page, and show the attributes if the customer wishes to do so.


    However I would really apreciate if someone could tell me the steps to install this javavascript http://www.tutorialtastic.co.uk/tuto...ith_javascript

    I thought I had mastered the art of copy and paste javascript! How wrong I was.

    Any help? What are the steps for add javascript. I have a jscript directory, I named my .js files with jscript_ as a prefix!

    Yet I am still confused. Thank you.

  2. #2
    Join Date
    Dec 2005
    Posts
    1,059
    Plugin Contributions
    2

    Default Re: How to add javascript! OMG?

    [FONT=Arial]Country Kitty Crafts[/FONT][FONT=Arial]
    [/FONT] [FONT=Garamond]
    [/FONT]

  3. #3
    Join Date
    Jun 2010
    Posts
    19
    Plugin Contributions
    0

    Default Re: How to add javascript! OMG?

    TShooters, mate that was one of the first places I went.


    However I don't understand how to apply the examples and description in there to my javascript because I don't see how it relates..

    Step 1
    I understand I need to have a jscript_ prefix for my .js file.


    Code:
    <script type="text/javascript">
    	function showStuff(id) {
    		document.getElementById(id).style.display = 'block';
    	}
    </script>
    This goes into my js file. Capiche.

    Step 2

    Code:
    <p><a href="#" onclick="showStuff('answer1'); return false;">What price are your apples?</a><br>
    <span id="answer1" style="display: none;">Our apples are 30 pence </span></p>
    I want this on my product listing page, so I place it in productlisting.php.

    This is causes a problem because I don't know how to get the syntax correct. When I do it, my whole product listing page shows up as blank.


    I hope this illustrates where I am going wrong with this.

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: How to add javascript! OMG?

    Quote Originally Posted by bigmo337 View Post
    I want this on my product listing page, so I place it in productlisting.php.
    I submit that /includes/modules/product_listing.php (which I think is what you really meant when you mentioned the non-existent productlisting.php filename above) is *not* the place to put any javascript unless you have very specific reason for putting it there. That's a PHP script file, dealing with business logic, not presentation/template content.

    If you want to output something to the page, you use the template file, which would be tpl_modules_product_listing.php. That's the more appropriate place to be making javascript calls to the .js files already loaded for the page.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. How do I add this javascript?
    By lolwaut in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 30 Jan 2012, 12:13 PM
  2. How do I add javascript rollover buttons to my header?
    By cuppycakez in forum Basic Configuration
    Replies: 2
    Last Post: 5 Apr 2009, 11:30 PM
  3. How do I add extra images to a product using javascript
    By southernlady in forum General Questions
    Replies: 8
    Last Post: 14 Jan 2009, 08:26 PM
  4. how do I add a javascript in product page
    By reza in forum Contribution-Writing Guidelines
    Replies: 0
    Last Post: 31 May 2007, 11:54 AM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR