Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

HELP-The CLICK function in my script wont work

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-17-2014, 06:27 PM
 
moetser moetser is offline
 

Advanced Member
  
Join Date: Jul 2012
Posts: 74
 

Default HELP-The CLICK function in my script wont work

Hi-I have an html file with a script that will overlay and display a box asking Are you 18 years or older? then there is a YES and a NO button -if you click YES the overlay disappears and you can see the site. If you click NO you are redirected to google.com

The html file on my local hard drive runs fine in a browser and you can click YES or NO and it does what it is supposed to.{other than the yes no images not directed correctly, that I can fix.

However, when I attempt to insert this into my home.tpl file everything other than the CLICK function works just fine. But you cannot click yes or no.

I know NOTHING and I mean NOTHING about java, scripting, php, I slightly comprehend a LITTLE html so any help would be so appreciated.

I ahve attached the 2 files-the pop18Clickworks.html is the file that works independently in a browser. The homeclick.tpl file is my home.tpl located in my skin/customer directory

Please help me, I know this is a simple script, syntax or format error and that I do not understand-it is all a foreign language to me

Thank you so much in advance for any assistance

Debbie
Xcart Gold pop18Clickworks.txthomeclick.tpl.txt
__________________
xcart gold
4.4.3
Reply With Quote
  #2  
Old 09-17-2014, 06:37 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: HELP-The CLICK function in my script wont work

No problem.

I think this is because X-cart's Smarty template engine is attempting to parse the {} tags in your JS code. Try wrapping it with {literal}{/literal} tags. Additionally you have used {} to display your script tags, when it should be <>. And finally you have included jQuery, and jQuery is already included in X-cart, and it should only be included once.

So you have not made one, but 3 separate errors! I think you should win a gold star.
Try this code, replacing everything you put after {include file="customer/pop18.html"}:
Code:
<script type="text/javascript"> {literal} $(document).ready(function(){ $( ".popup_img_yes" ).click(function() { $( ".popup" ).fadeOut( 1200 ); }); $( ".popup_img_no" ).click(function() { window.open("http://www.google.com","_self"); }); }); {/literal} </script>

So you also need to remove this line: {script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'}{/script}

And I'm not sure about including a .html file like you have here: {include file="customer/pop18.html"}

I would rename that file to pop18.tpl and pull it in with:
{include file="customer/pop18.html"}

But it may be fine, I've never tried to include a .html file before. Leave it that way at first and tell me if it worked!
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 09-17-2014, 07:00 PM
 
moetser moetser is offline
 

Advanced Member
  
Join Date: Jul 2012
Posts: 74
 

Default Re: HELP-The CLICK function in my script wont work

WOW ALMOST ALL FIXED-just 1 last thing- now it all works with just one problem left-it is supposed to clear the overlay when you click YES that works fine-but it is doing the same thing for when you click NO-When you click NO it is to redirect to google.com-

But now it just clears the overlay no matter which one you click see quietcricketus.com

How can i fix that?

MIKE YOU ARE MY NEW BEST FRIEND!!!! I have been trying for months to find a way to get that restriction on the home page. I cannot thank you enough!!
__________________
xcart gold
4.4.3
Reply With Quote

The following user thanks moetser for this useful post:
totaltec (09-17-2014)
  #4  
Old 09-17-2014, 07:07 PM
 
moetser moetser is offline
 

Advanced Member
  
Join Date: Jul 2012
Posts: 74
 

Default Re: HELP-The CLICK function in my script wont work

I removed the include html file as it does not work in the home.tpl

however the html file run directly in a browser does redirect to google.com
but the same exact code in the home.tpl is not redirecting to google.com whn you click NO it clears the overlay the same as when you click YES

I cannot figure out why
__________________
xcart gold
4.4.3
Reply With Quote
  #5  
Old 09-17-2014, 07:34 PM
 
moetser moetser is offline
 

Advanced Member
  
Join Date: Jul 2012
Posts: 74
 

Default Re: HELP-The CLICK function in my script wont work

Just noticed another problem-I only have this in the home.tpl- however, the same popup keeps coming up everytime you click on any and all pages

why would it do that if I only have the code in home.tpl? is it fixable?
__________________
xcart gold
4.4.3
Reply With Quote
  #6  
Old 09-17-2014, 08:13 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: HELP-The CLICK function in my script wont work

Cool, you have an online vape shop. Sweet.

Sure if the code is in home.tpl, it will be called on every page. customer/home.tpl is the container for every customer side page.

If you want to restrict it to the home page, you need to add an if statement around all the code.
Code:
{if $main eq "catalog" and $current_category.category eq ""} All your code above goes here {/if}
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #7  
Old 09-17-2014, 08:18 PM
 
moetser moetser is offline
 

Advanced Member
  
Join Date: Jul 2012
Posts: 74
 

Default Re: HELP-The CLICK function in my script wont work

Yes, we are just starting out, but if you can have a discount for life!

I will try to enter that if statement and be right back- not exactly sure where it goes, we will see lol

What about when you click on the NO button it does not redirect to google like it is supposed to it just fades the overlay away like when you click yes-

in the independent html file in a browser it redirects to google when you click no, but does not in the home.tpl file
__________________
xcart gold
4.4.3
Reply With Quote
  #8  
Old 09-17-2014, 08:19 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: HELP-The CLICK function in my script wont work

Debbie,
I just read through your file pop18Clickworks.txt

That file contains a <html> tag <head> tag, and so on. You should not be including all of that stuff!

To explain, your home.tpl already has all those pieces, if you include them a second time it will make for a poorly formatted web page. Rename the file to .tpl, and include only the div class="popup"

Just this part:
Code:
<div class="popup"> <!-- popup content start || copy this to the end of the file--> <div class="popupWindow"> <div class="popup_txt"> Are you 18 years of age or older? </div> <div class="popup_img"> <img src="/skin/my_skin/images/yes.png" class="popup_img_yes"/> <img src="/skin/my_skin/images/no.png" class="popup_img_no"/> </div> </div> </div>
Then you need to take the style out and include that in your home.tpl/ It would be better to include it via an external style sheet.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #9  
Old 09-17-2014, 08:30 PM
 
moetser moetser is offline
 

Advanced Member
  
Join Date: Jul 2012
Posts: 74
 

Default Re: HELP-The CLICK function in my script wont work

ok-I am attaching the home.tpl as it stands now for you to see

I am not using or calling the pop18 html file I took that "include" out

yeah I had already removed all the STYLE stuff to the css file

so here is the only file i am using which is the home.tpl file attached

I am sure I entered the if statement wrong lol

also, the popup comes up on the home page and when you click it clears out the overlay

but when you click NO it is not redirecting to google.com

the popup is still coming up on all the other pages, only you cannot click it to make it go away

please see attached file that I apparently screwed up

sendtomike.tpl.txt
__________________
xcart gold
4.4.3
Reply With Quote
  #10  
Old 09-17-2014, 08:31 PM
 
moetser moetser is offline
 

Advanced Member
  
Join Date: Jul 2012
Posts: 74
 

Default Re: HELP-The CLICK function in my script wont work

oops sorry I am sleepy-that one still has the style nonsense in it-I am removing it now
__________________
xcart gold
4.4.3
Reply With Quote

The following user thanks moetser for this useful post:
totaltec (09-17-2014)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:41 AM.

   

 
X-Cart forums © 2001-2020