Announcement

Collapse
No announcement yet.

Using Java script inside product pages.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using Java script inside product pages.

    Hi Folks,

    This is kind of following on from a previous post I put the other day, but since it has slipped down the page due to all the new postings I though I would start a fresh one. Also, the original post had moved sideways so I figured it would be handy to have this information in the community somewhere.

    I want to have a popup window open with our data protection notice in, but using the extended information doesn't really help. I am going to add in 4 attributes to my some of my products, where you can opt in or out of receiving further info from my company or the company whose products you are purchasing. Before anyone points out how annoying this is, I know, but I'm waiting for Actinic to add in some more variables to their built in DP notice (see my previous post: User Definable Fields/Data Protection Notice ). and I have to put this on the site.

    I need it to work like this:

    Data protection notice:

    Our data protection notice can be read by clicking
    here

    You then get the DP notice open in a small buttonless, menuless, addressbarless (is that even a word?!) window. Underneath you'll then get the 4 opt in or out check boxes. I'm probably going to have to put some sort of text saying that if you are ordering more than 1 product you only need to fill this out once. A bit of a messy way around it but I'm kind of over a barrel on this one.

    Can I just bang the java straight into the product description like I could with html? Or do I need to add it somewhere else into the text | html? I'm rubbish with java so if anyone has a usable script already or can point to somewhere where I download one then that would be great. I've tried a half-arsed way of copying the html from Dreamweaver into the product description using the 'open browser window' behaviour, but as you can tell by the fact that I'm adding this post, it didn't work!

    Any help would be very much appreciated.

    Cheers
    Charles

    www.ahapremier.com

    _________________________
    B&M Design & Advertising Ltd
    www.bm-group.co.uk


    #2
    Can I just bang the java straight into the product description like I could with html?
    Yes. You can embed JavaScript into a product description. It's just an HTML tag that says there's a script starting after all. Just use the !!< and >!! Actinic escape tags around it.

    e.g.

    !!<<script language="JavaScript">alert('Hello world');</script>>!!

    If you've got many products that need to use the same code you can put a function into Act_primary.html and call it from your product pages.

    You can also include a file containing the javascript code via a statement like:-

    !!<<script language="JavaScript" src="mycode.js" type="text/javascript"></script>>!!

    This way is pretty economical for the occassional product as the code is only loaded when the product displays.



    Norman
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks Norman,

      Could I upload the 'open browser window' command from Dreamweaver and call that from the product description? I have it as Java Script file. I take it that it would have to be in the cgi-bin for it to work? Since I'm pretty useless at hard coding, could I place it in Dreamweaver and fill in the details of the window size I want to open, then copy the html into the product window with !!< and >!! either side?

      Apologies if I'm talking rubbish, I'm pretty new to all this!

      Thanks
      Charles

      _________________________
      B&M Design & Advertising Ltd
      www.bm-group.co.uk

      Comment


        #4
        JavaScript doesn't need to be in cgi-bin. It's either embedded in the product page code or loaded from a file via the

        !!<<script language="JavaScript" src="mycode.js" type="text/javascript"></script>>!!

        In the latter case just put the file mycode.js in Site1 and Actinic will find it and upload it for you.

        Smoke won't come out if you experiment so just have a go with something simple like the Hello World example above and once you understand what's happening try pasting in the bit of code that DW generates.

        Norman
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Time to start fettling! I'll post what happens back here later.

          _________________________
          B&M Design & Advertising Ltd
          www.bm-group.co.uk

          Comment


            #6
            Firstly - Thankyou Norman for your help on this. You didn't just hand over the answer - you pointed me in the right direction and I worked it out for myself. A far better way to master something.

            I have now managed to get this to work - heres what I did:

            I ended up just inserting the java straight into Actinic rather than loading the script. Since I can't actually write Java I did a few searches and found Lycos' Java tutorials (which by the way are fantastic if you know nothing about manually inserting Java - have a look at: http://www.tripod.lycos.co.uk/webmas...pt/index.phtml )

            I then pasted what they had used into Dreamweaver to play about with and try and get the required result. Once I had it working properly I just copied the script straight out of DW and into my full description window as follows:

            Data Protection Notice:
            To see our data protection notice click !!<<a HREF="javascript:void(0)" onClick="window.open('http://www.ahapremier.com/data_protection.htm', 'spencer', 'width=375,height=500');" >Here</A>>!!

            Don't ask me what the 'spencer' bit means - I don't have a clue - but either way it doesn't seem to work if I take it out.

            Cheers
            Charles

            _________________________
            B&M Design & Advertising Ltd
            www.bm-group.co.uk

            Comment


              #7
              Charles,

              I looked around in my list of readme's and discovered that I'd already written (and forgot about) an extension that allows you to make an arbitrary number of Additional prompts at the checkout page.

              This basically hijacks the General Info / User Defined 3 prompt and if it contains the "|" char splits it into lots of sub-prompts. If it contains no "|" character then it behaves as normal.

              I.e. if prompt is Age|Sex|Height then three sub-prompts will be displayed.

              I've attached the instructions on how to implement it as a text file.

              It wouldn't be too hard to alter this to have it produce checkboxes instead of prompts.

              Norman
              Attached Files
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Have followed your readme successfully, Norman, but was wondering if their is a way to preview it locally before uploading it onto the site? If its wrong, doesn't work or needs to be tweaked I don't want to have to revert back to how it was, then reload it, put the corrections back and then re-upload it!

                I seem to remember seeing somewhere about configuring a local server to get a full preview running locally? Does anyone know anything about this?

                _________________________
                B&M Design & Advertising Ltd
                www.bm-group.co.uk

                Comment


                  #9
                  Yeah, get hold of the latest Advanced User Guide from http://www.actinic.co.uk/support/downloads.htm and this contains a step-by-step guide to setting up a local webserver.

                  Comment


                    #10
                    You can't run any of the Perl based pages ( search, add to cart, checkout ) without a server somewhere in the loop.

                    Installing the standalone server as per the advanced guide is easy and you can export / import the live site and test site's network settings to a textfile so it's easy to switch between one and the other.

                    Norman
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      Nearly there! I've set up a local server so I can preview what I've done before putting the content live, but its not quite working right.

                      I followed the advise of Stu who had a post a while ago entitled: Click to accept terms & conditions. He converted a text box to a checkbox to get someone to accept the terms and conditions on his site. When you look at the 'Act_Order02.html' template in Dreamweaver you can see that it is supposed to be using a checkbox not a text box, but when you preview locally is reverts to a textbox.

                      Normans 'Char | split' works a treat (cheers Norman) but it just needs some tweaking. Norman, do you know if your hack is causing it to force back to a textbox? Anyone got any ideas? I have to have this nailed by Wednesday afternoon!

                      Thanks for everyones help on this by the way, much appreciated.

                      Cheers
                      Charles

                      _________________________
                      B&M Design & Advertising Ltd
                      www.bm-group.co.uk

                      Comment


                        #12
                        That patch was designed to add in additional text fileds.

                        I've rejigged it to produce checkboxes instead and added an optional bit that will prevent the page from being submitted unless all checkboxes are ticked.

                        Norman
                        Attached Files
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          Norman, I really can't thank you enough for your help on this. Its all working sweetly now, feel free to have a gander at www.ahapremier.com

                          Thanks Again
                          Charles

                          _________________________
                          B&M Design & Advertising Ltd
                          www.bm-group.co.uk

                          Comment

                          Working...
                          X