TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

TBS Field Within Javascript

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Anthony
Date: 2012-10-10
Time: 06:47

TBS Field Within Javascript

I am trying to pass a php variable using TBS to a section of javascipt. However it does not appear to be working. Can we use a TBS field within a block of javascript code like seen below?

var hours = [onshow.strHours; noerr];
var minutes = [onshow.strMinutes; noerr];
var seconds = [onshow.strSeconds; noerr];
By: Skrol29
Date: 2012-10-12
Time: 00:19

Re: TBS Field Within Javascript

hi Antony,

It depends of what $strHours contains.
What is the value of $strHours and what do you expect to have in your Java-script ?
By: Anthony
Date: 2012-10-12
Time: 01:19

Re: TBS Field Within Javascript

Hours would hold a value between 0 and 24, minutes and seconds between 0 and 60.
By: Skrol29
Date: 2012-10-12
Time: 10:13

Re: TBS Field Within Javascript

So there is no formating needed, it should be working.
What is the problem you're observing?
By: Anthony
Date: 2012-10-12
Time: 14:46

Re: TBS Field Within Javascript

Yep, you're right. It does work once the variable name matches the variable in the php file. :) I just noticed the discrepancy. That's what late night coding gets you.