| ||||||||||
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 |
#11
|
|||||||
|
|||||||
Re: Age Calculation
Try using this:
Code:
It auto-calculates on page load, but it requires jquery (no worry, x-cart comes with it and will not have any issues :P) so importing into another program won't work later unless it uses jquery. |
|||||||
#12
|
|||||||
|
|||||||
Re: Age Calculation
Not working for me, just showing the "Results".
http://littlepuppiesonline.msidesigns.com/product.php?productid=1&cat=28&page=1 I also tried scaling it down since we don't need some of the other calculations there were in the original form. Code:
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#13
|
|||||||
|
|||||||
Re: Age Calculation
Do you think we'd better off storing the calculation results as a variable and displaying it like the rest of the site and not using the <form>?
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#14
|
|||||||
|
|||||||
Re: Age Calculation
Thankgod firebug exists.
Enter numbers for their birthdays without 0's preceding such as 1 2 3 4 5 6 7 8 9 10 11 12 13 14 etc You also stripped out too many {} brackets. Trying to find where you're missing one... Edit: Find this: Code:
On the line before it, add a } |
|||||||
#15
|
|||||||
|
|||||||
Re: Age Calculation
Ok so I tried it this way. I compared the modified one against the original and made sure all of the { } were correct.
It's still not displaying the info. Code:
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#16
|
|||||||
|
|||||||
Re: Age Calculation
I see what you did.
You moved stuff around as well. Notice my code: Code:
I ended the opening literal statement right before using smarty, and then started again after it. This is due, as I said before, smarty using {} and javascript as well... They don't play nice together. Your code keeps the smarty calls in literal Code:
if its taken literally, it will be. The actual values are those. Another thing you did was change the form. Code:
Yours: Code:
Thing is, the script only outputs the variable to a form named birthday. You changed it to age, thus another issue. In any case... The code... Already stripped out some code, removed extra spaces, changed it so the form it outputs to is called age, changed form name to age and fixed literal placing. Tested and works... Code:
|
|||||||
#17
|
|||||||
|
|||||||
Re: Age Calculation
Thanks for all your help on this. I'm still only getting "Result" in the form box.
I did check the fields in the product. I still had 08 as the month, but that didn't make any difference when I changed it to 8
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#18
|
|||||||
|
|||||||
Re: Age Calculation
Don't use 08 or 09. Javascript won't accept it as a number.
Edit: Checked your site, going thru the javascript now to see what changed... Edit2: Found it. Your site: Code:
Proper: <form name="age"> <input name="age" size="40" value="Result"><br> </form> |
|||||||
#19
|
|||||||
|
|||||||
Re: Age Calculation
Quote:
Yeah that's what I had on there. I even check the source code. hmmm Maybe it's because of Firefox? I did see in the code that the var's are being set to the correct day,month,year. Edit: Nope IE blows too. :P OMG this is so stupid, why is it not working. I was asking before, is there a different way to store the calc and display it not using the form? Really what I'd like is the details page to look like is: Puppy Name Junior is 4 months, 2 days old. Other Sites Sell For: $699.00 Our price: $0.01
__________________
X-Cart 4.3 Joomla Among other things |
|||||||
#20
|
|||||||||
|
|||||||||
Re: Age Calculation
Doing this in the php file would seem to be easier and more efficient - if you are comfortable modifying the php files. You can continue to use the extra fields to capture the birthdate. In php, you can use the time function to get the current date. You can use strtotime to turn your string date in the extra fields to a timestamp so you can do the the math. Then, you use regular math to format the difference in seconds into years/months/days. While it is not doing exactly what you want, if you understand the concepts in this thread - it helps to explain how the extra fields are accessible in the php, and how to pass the result to the templates.
__________________
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) |
|||||||||
|
|||
X-Cart forums © 2001-2020
|