Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22
  1. #11
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Attribute Selection and JavaScript

    Well, without going back to check I think that you are adding the image as a comment. Is that correct?

    Things to remember:

    You need the ID of the image to always match the getElementById statement in the javascript.

    Beyond that if the images always correspond to the same number then you have no problems. So if "72" is always font4 then that is not an issue.

  2. #12
    Join Date
    Dec 2006
    Location
    Seligman, MO U.S.A.
    Posts
    2,101
    Plugin Contributions
    5

    Default Re: Attribute Selection and JavaScript

    Yes, that is correct......I added the default image in the attributes' comments.

    But, it looks like I YAY!ed too soon, as what works perfectly on my test site isn't working at all on another site. And I've done everything EXACTLY the same, but of course the numbers have changed.
    Of course I created all my images and uploaded them.

    Created a option name of: Inscription Font. In the comments added:
    Code:
    <img src="images/amazon.jpg" alt="select" id="img1"/>
    which gave me my image of amazon.jpg on the page.

    There are 11 different font selections for this product.....actually a few products.....ID's from 915-925., with 915 being the amazon.jpg

    Then I redone the script from mine to look like this:

    Code:
    <script language="javascript" type="text/javascript"><!--
    function changePicture(pValue)
    {
        var vSelection = "images/amazon.jpg";
        switch(pValue)
        {
            case "925": vSelection = "images/corsiva.jpg";
            break;
            case "924": vSelection = "images/impact.jpg";
            break;
            case "923": vSelection = "images/georgia.jpg";
            break;
            case "922": vSelection = "images/fiolex.jpg";
            break;
            case "921": vSelection = "images/edwardian.jpg";
            break;
            case "920": vSelection = "images/commercial.jpg";
            break;
            case "919": vSelection = "images/clown.jpg";
            break;
        case "918": vSelection = "images/cloister_black.jpg";
            break;
        case "917": vSelection = "images/brush455.jpg";
            break;
        case "916": vSelection = "images/angelina.jpg";
            break;
            
            default:vSelection = "images/amazon.jpg";
    
        }
        document.getElementById("img1").src = vSelection;
    }
    //--></script>
    Do you see anything wrong with this code?

    Also, as this site isn't 'Live' to the public yet, I've pm'ed you the url.............if you wouldn't mind taking a look at it. That way, you can view the source, which to me......looks just like the source on my site, with the exception of the ID's and images being different.

    Thanks........again.
    Teach them to shop and they will shop today;
    Teach them to Zen and they will OWN a shop tomorrow!

  3. #13
    Join Date
    Dec 2006
    Location
    Seligman, MO U.S.A.
    Posts
    2,101
    Plugin Contributions
    5

    Default Re: Attribute Selection and JavaScript

    Nick......nevermind about all the above. I had just forgot to put the code in modules/attributes.php. Once I done that, it all worked.


    Now, if it would just validate...........but that's a different day......Thanks for reading all this......again.
    Teach them to shop and they will shop today;
    Teach them to Zen and they will OWN a shop tomorrow!

  4. #14
    Join Date
    Dec 2006
    Location
    Seligman, MO U.S.A.
    Posts
    2,101
    Plugin Contributions
    5

    Default Re: Attribute Selection and JavaScript

    I just got the validation part figured out, also. In the modules/attributes.php file I changed this:

    Code:
    onChange="changePicture(this.value);
    to this:

    Code:
    onchange="changepicture(this.value);
    And in the includes/modules/pages/product_info/jscript_main.php, I changed this:

    Code:
    function changePicture(pValue)
    to this:

    Code:
    function changepicture(pValue)
    And got a valid markup.......and it all still works! W3C says....."No Caps" in that type of script.
    WooHoo! I'm a happy camper, now!
    Nick, I sure do appreciate all the help, and for putting up with me.
    Teach them to shop and they will shop today;
    Teach them to Zen and they will OWN a shop tomorrow!

  5. #15
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Attribute Selection and JavaScript

    Well, done. Glad it all works for you.

  6. #16
    Join Date
    Jan 2011
    Posts
    22
    Plugin Contributions
    0

    Default Re: Attribute Selection and JavaScript

    Hi,

    i have tried to implement this code and i cant seem to get the onchange to work. Wat i am trying to achieve is for when the user selects a different frame it changes the background image behind the product image. Can anyone help?

    see link for test site
    http://jimpicot.com/shop/index.php?m...&products_id=3

  7. #17
    Join Date
    Jan 2011
    Posts
    22
    Plugin Contributions
    0

    Default Re: Attribute Selection and JavaScript

    Quote Originally Posted by niccol View Post
    Well, done. Glad it all works for you.
    can you help me? i am trying to achieve the same thing.

    http://jimpicot.com/shop/index.php?m...&products_id=3

  8. #18
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Attribute Selection and JavaScript

    You are not far off.

    Sorry I made an error. I thought the quotes in here were wrong. But that may have been my mistake.

    function swapframe(imgref) {
    bgfile = 'url(<?php echo DIR_WS_IMAGES; ?>frames/' + imgref + '.jpg)';
    document.getElementById("frameimage").style.backgroundImage = bgfile;
    }

    I would put dome alerts in the javascript to see if the values are being set correctly.
    Last edited by niccol; 1 Mar 2011 at 03:40 PM. Reason: Foolishness

  9. #19
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Attribute Selection and JavaScript

    Jim,

    Sorry I was going quickly in my previous answer and it wasn't that helpful or feindly. Try adding the url as text rather than using <?php ?> . The php won't be parsed in a .js file.

    Nick

  10. #20
    Join Date
    Jan 2011
    Posts
    22
    Plugin Contributions
    0

    Default Re: Attribute Selection and JavaScript

    Quote Originally Posted by niccol View Post
    Jim,

    Sorry I was going quickly in my previous answer and it wasn't that helpful or feindly. Try adding the url as text rather than using <?php ?> . The php won't be parsed in a .js file.

    Nick
    Hi,

    i have removed the php from the javascript. it still isnt working. how can i put Dom requests so that i can see the values? im noob at php/javascript

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v150 Attribute images not in-line with attribute selection
    By JacobBushnell in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 14 Aug 2012, 11:51 PM
  2. Replies: 5
    Last Post: 2 Jan 2010, 08:44 PM
  3. Default Attribute Selection and Add to Cart
    By onurich01 in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 17 Jul 2009, 05:47 PM
  4. Attribute Drop Downs and Color Selection
    By Jo3y in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 5 May 2007, 06:14 AM

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