Categories > TinyButStrong general >

Why isn't format working as it should? What am I doing wrong?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Billy
Date: 2007-04-17
Time: 03:02

Why isn't format working as it should? What am I doing wrong?

I have this:

<select name="day">
<option value="">DD</option>
<option value="[days.val;block=option]">[days.val;frm=00]</option><option>[var.fields.day;ope=html;select]</option>
</select>

...and this:

<?
require_once("tbs_class.php");
require_once("tbs_plugin_html.php");

for ($i = 1; $i <= 31; $i++) {
    $days[] = $i;
}

$tbs = new clsTinyButStrong;
$tbs->LoadTemplate("applicants_form.html");
$tbs->MergeBlock("days", $days);
$tbs->Show();
?>

But the frm doesn't work. All I get are numbers with no zeros on the left.

Any idea? I may be too tired. :(

Thanks.
By: Skrol29
Date: 2007-04-17
Time: 11:02

Re: Why isn't format working as it should? What am I doing wrong?

Hi,

What format do you need ?
If it's with two digits, the it should be "frm=0.00"
By: Billy
Date: 2007-04-17
Time: 17:15

Re: Why isn't format working as it should? What am I doing wrong?

I need to put zeros on the left when needed, like this:

01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, ...

frm=0.00 gives me this:

1.00, 2.00, 3.00, ...

Is it possible?
By: Skrol29
Date: 2007-04-17
Time: 18:52

Re: Why isn't format working as it should? What am I doing wrong?

Not possible with parameter "frm", it works only for dates.
You have to use your own formating function, to use with parameter "onformat".
By: Billy
Date: 2007-04-17
Time: 19:19

Re: Why isn't format working as it should? What am I doing wrong?

Ok, I get it. As I couldn't find an example of onformat, can you confirm this is correct? I mean, it works, just want to be sure.

<select name="day">
<option value="">DD</option>
<option value="[days.val;block=option]">[days.val;onformat=add_left_zero]</option><option>[var.fields.day;ope=html;select]</option>
</select>

<?
require_once("tbs_class.php");
require_once("tbs_plugin_html.php");

for ($i = 1; $i <= 31; $i++) {
$days[] = $i;
}

$tbs = new clsTinyButStrong;
$tbs->LoadTemplate("applicants_form.html");
$tbs->MergeBlock("days", $days);
$tbs->Show();
?>

function add_left_zero($field_name, &$current_value) {
    $current_value = sprintf("%02d", $current_value);
}

Thank you!
By: Skrol29
Date: 2007-04-18
Time: 00:35

Re: Why isn't format working as it should? What am I doing wrong?

Hi,

I don't know if "%02d" is correct, but the TBS function is correct and the HTML snippet too.
By: Billy
Date: 2007-04-18
Time: 00:42

Re: Why isn't format working as it should? What am I doing wrong?

Ok, many thanks!

(and yes, I was inquiring about the TBS use :) )
By: Skrol29
Date: 2007-04-18
Time: 11:03

Re: Why isn't format working as it should? What am I doing wrong?

I was reading my previous message again :
"Not possible with parameter "frm", it works only for dates."

I meant parameter "frm" can add leading zeros only for dates.
"frm" can also format numbers, but not the way you needed.