| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Age Calculation | ||||
|
|
Thread Tools | Search this Thread |
#21
|
|||||||
|
|||||||
Re: Age Calculation
gb,
I struggled with java vs php. I understand just enough to be dangerous with both. However Java is easier and code is more widely available. I've looked into PHP Age caculators and I've found a few. I'm just drawing a blank on how to make it work in my X-Cart.
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#22
|
|||||||
|
|||||||
Re: Age Calculation
I tried messing around with PHP code this week and I can get it to pull the extra field variables, but It's not displaying correctly on the site.
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#23
|
|||||||
|
|||||||
Re: Age Calculation
Quote:
That's a blanket problem, like "My car doesn't work". Nothing can help unless you actually describe what doesn't work :P Is it displaying at all? If you have it and it's own div in an {if} section, does the div show up and the variable is just missing? |
|||||||
#24
|
|||||||
|
|||||||
Re: Age Calculation
Here's the code in the tpl.
Code:
Here is the error. As you can see it's pull in the variables. Error: Smarty error: [in modules/Age_Calculation/age.tpl line 12]: syntax error: unrecognized tag: $day=(empty($day))?'1':$day; list($this_year, $this_month, $this_day) = explode(' ',date('Y n j')); $age = $this_year - $year; if ($month>$this_month||($this_month==$month&&$this_d ay<$day)) { $age--; (Smarty_Compiler.class.php, line 446) in /home/minfinge/public_html/littlepuppiesonline.com/include/lib/smarty/Smarty.class.php on line 1093 var day = 8; var month = 17; var year = 1977; function checkCurAge($year,$month,$day='') return $age; }
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#25
|
|||||||||
|
|||||||||
Re: Age Calculation
php code does not go in the tpl files - it goes in the php files.
Perhaps you are closer to your desired result with the javascript as Tal has already provided code to you that works and you are more comfortable with javascript. If you are having trouble with the submit form, try taking that out - there is no reason for it as you are getting the data from extra fields, not a submission by the user.
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold (CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module) |
|||||||||
#26
|
|||||||
|
|||||||
Re: Age Calculation
GB2...I have not gotten the Javascript to display the age calculation yet.
Look below "Our Price" It says Results. http://littlepuppiesonline.msidesigns.com/product.php?productid=1&cat=10&page=1
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#27
|
|||||||||
|
|||||||||
Re: Age Calculation
One possible issue - you have a form inside a form - which is not valid html.
I've not looked at the javascript - but maybe Tal can comment about where to put this code? If you want it inside the main form - maybe drop the form submission and just use the javascript date functions you have to output the data without a form submission
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold (CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module) |
|||||||||
#28
|
|||||||
|
|||||||
Re: Age Calculation
Quote:
Actually that's what I'd prefer to do is just display the calc answer without the form. The form is only there because that's what came in the code I found online.
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#29
|
|||||||||
|
|||||||||
Re: Age Calculation
Just noticed that when Tal told you he does not see the <form> in firebug, you suggested that maybe it was firefox. Firebug often does not display incorrect code. You'll see it in the page source, but firebug does not know what to do with it since it is wrong.
Seems to me that this is even more evidence that your problem is that your age form is being incorrectly placed inside another form. If so - your solution is to move it to a valid location or revise the javascript you have copied to not use a form submission. You could verify that this is indeed the problem by trying to move that form to a valid location.
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold (CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module) |
|||||||||
#30
|
|||||||
|
|||||||
Re: Age Calculation
Quote:
I'd rather have the script not use the form and then I'd be able to place the tpl call where ever I wanted. Only problem is I don't understand how to display the age calc answer using java. Any help would be great.
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
|
|||
X-Cart forums © 2001-2020
|