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

javascript error on register.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-30-2008, 04:31 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default javascript error on register.tpl

I'm doing some changes on my website when suddenly I start getting a javascript error when I try to register, modify account or checkout as an annonymous user. The error is "return statement outside function". I tried with the original register.tpl but the error is still there. The only return statement I see in register.tpl is this function:


<script type="text/javascript" language="JavaScript 1.2">
<!--
var is_run = false;
function check_registerform_fields() {ldelim}
if(is_run)
return false;
is_run = true;
if (check_zip_code(){if $default_fields.email.avail eq 'Y'} && checkEmailAddress(document.registerform.email, '{$default_fields.email.required}'){/if} {if $config.General.check_cc_number eq "Y" AND $config.General.disable_cc ne "Y"}&& checkCCNumber(document.registerform.card_number,do cument.registerform.card_type) {/if}&& checkRequired(requiredFields)) {ldelim}
document.registerform.submit();
return true;
{rdelim}
is_run = false;
return false;
{rdelim}
-->
</script>



wich is then called in the beginning of the form

<form action="{$register_script_name}?{$smarty.server.QU ERY_STRING|amp}" method="post" name="registerform" onsubmit="javascript: check_registerform_fields(); return false;">

and after that with the submit button

{include file="buttons/submit.tpl" button_title=$but_title type="input" style="button" href="javascript: return check_registerform_fields();"}

Now all code above is original x-cart code (except for the button_title). I have no idea why it stoped working. I tried taking out "return" from the button href and then it works as far as showing the "missing something" message but if there is a missing info on the page instead of staying on the same page as it should it redirects to a blank page. Any help is appreciated.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #2  
Old 01-30-2008, 04:41 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: javascript error on register.tpl

If it suddenly stopped working, it is definitely something that you changed, it may not be in that exact template. Did you make any changes to the individual registration templates (billing, shipping, etc) or add any other JS that might conflict with the reg script?
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 01-30-2008, 06:16 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: javascript error on register.tpl

Thanks for your reply balinor. Found the problem. It wasn't register.tpl or any other registration template. It was the button.tpl template. I wanted to get rid of the whole ridiculous table in table in table... in button.tpl so I replaced it with a <div> and <a> tags. Originally there was onclick="{$js_link}" statement which I changed to href="{$js_link}" and put it in the <a> tag. Well apparently x-cart didn't like that. When I moved it to the <div> tag as onclick="{$js_link}" it worked. I don't like it much like this but if that's the way to make it work...
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #4  
Old 01-30-2008, 06:16 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: javascript error on register.tpl

Yea, don't you love that default button? What a mess!
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #5  
Old 01-30-2008, 09:30 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: javascript error on register.tpl

Just a few months ago I was new to x-cart but now I can say it is not just the buttons that are a mess. Well I guess I don't have to tell you this...
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 11:24 AM.

   

 
X-Cart forums © 2001-2020