Announcement

Collapse
No announcement yet.

email a friend problem

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

    email a friend problem

    Hi all,
    I'm playing with the 'email a friend' function from p47 of the advanced guide and have a small issue I need to overcome.

    If I do not enter anything into the email field (ie it is left 'null') and just click the 'send e-mail' icon then the product is added to the cart rather than the entry being dropped as invalid.

    You can see the issue by following this link and clicking the email icon:
    http://www.scartplug.com/acatalog/XHT501.html

    Is there any way of forcing the script to ignore null entries?

    J
    www.blueshell.co.uk
    www.scartplug.com
    www.vivanco-direct.com

    #2
    Fixed it...

    Decided I'd just delete the email links after the products - they looked too messy.

    So now I just have an email a friend link on the side that points to the home page - far simpler and cleaner looking!

    J
    www.blueshell.co.uk
    www.scartplug.com
    www.vivanco-direct.com

    Comment


      #3
      I see what you are trying to do.

      I think the reason you are adding to cart was that the tell a friend box is within the same form tags as the add to cart form, and it would have to be. What I suggest you do is write it as:

      <script>
      function sendFriend(email) {
      var pagename = document.location.href;
      window.location.href = 'mailto:' + email + '?body='Your friend thought you should look at ' + pagename;
      return false;
      }
      </script>

      Then put a button next to the tell a friend box:
      <input type="button" value="Send" onclick="sendFriend(document.forms[1].tellfriend.value)" name="tellfriend" />

      This assumes you still have the tellafriend box within the add to cart form and that this form is the second form on that page (with the search box form first). You may have to tweak the scripting here.
      http://www.johnsons-seeds.com - Actinic plugins, remote add to cart and custom CMS
      http://www.dtbrownseeds.co.uk - More seeds and plants....
      http://www.mr-fothergills.co.uk - Well it used to be Actinic...

      Comment


        #4
        The reason this is failing for you is that you've decided to switch from the patch's

        <input type=button value="OK">

        line (which won't submit the form and Add to Cart) to an

        <input type=image ...>

        tag which will Add to Cart.

        Go back to the former and all will be OK.

        Alternatively:

        The Button doesn't actually do anything. It simply is there so that the customer has something to click and thus fire the onchange event. You could do something like this instead

        <img style="cursor: pointer" src="mybutton.gif" width=20 height=20>

        which displayes an image of your choice but with some associated style so it looks clickable.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Aha. All is clear now.

          Thanks Norman,
          I see how the code works now - and understand the strange behaviour of the 'send mail' button.

          That said, I removed the email a friend box/button as it tended to clutter the design.

          Thanks again
          J
          www.blueshell.co.uk
          www.scartplug.com
          www.vivanco-direct.com

          Comment


            #6
            hello,

            I was wondering if there was a way of having a normal button to link to a page where you can email the previous page to a friend?

            for example I have a icon in a nav bar, I want the csmr to click that, and for a page to open where they can input the desired emaill addy and then send...

            and then maybe move back to the original page they were on :P

            anyone know how to do this?

            cheers

            Ben..
            www.bathroomexpress.co.uk

            Comment


              #7
              Some JavaScript like opener.location.href will return the URL of the page that opened this one.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment

              Working...
              X