Categories > TinyButStrong general >

Quick help please

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: RwD
Date: 2004-05-24
Time: 23:03

Quick help please

Hi, I am doing a project and I am not going to make the deadline...
That is, if I get any more of these things...

I want to do something for Javascript.
The supposed result should be like this:
<script language="JavaScript">
function UpdateCountryInfo( objCountryId )
{
    // Pricing variables
    var scArray = new Array();
    // Groups first
    scArray[ 'R1_package_O1' ]    = new Array();
    scArray[ 'R1_package_O2' ]    = new Array();

    scArray[ 'R1_package_O1' ][ 'order' ]    = 2000;
    scArray[ 'R1_package_O1' ][ 'cost' ]    = 400;
    scArray[ 'R1_package_O1' ][ 'order' ]    = 3000;
    scArray[ 'R1_package_O1' ][ 'cost' ]    = 300;
    scArray[ 'R1_package_O2' ][ 'order' ]    = 3000;
    scArray[ 'R1_package_O2' ][ 'cost' ]    = 600;
    scArray[ 'R1_package_O2' ][ 'order' ]    = 4000;
    scArray[ 'R1_package_O2' ][ 'cost' ]    = 500;
}
</script>

I came up with this which isn't working:
HTML:
<script language="JavaScript">
function UpdateCountryInfo( objCountryId )
{
    // Pricing variables
    var scArray = new Array();
    // Groups first
    {prices_hdrs;block=begin;headergrp=test}
    scArray[ '{prices_hdrs.sc_group_combi;headergrp=test}' ]    = new Array();
    {prices_hdrs;block=end}

    {prices;block=begin}
    scArray[ '{prices.sc_group_combi}' ][ 'order' ]    = {prices.sc_order};
    scArray[ '{prices.sc_group_combi}' ][ 'cost' ]    = {prices.sc_cost};
    {prices;block=end}
}
</script>

PHP:
$tbs->LoadTemplate($dir['templ'] . 'coc_user_input.htm');
$tbs->MergeBlock( 'prices_hdrs', $DB->Link_ID, 'SELECT * FROM sc, sc_group WHERE sc_group_id = sc_group ORDER BY sc_group' );
$tbs->MergeBlock( 'prices', $DB->Link_ID, 'SELECT * FROM sc, sc_group WHERE sc_group_id = sc_group ORDER BY sc_group' );
$tbs->Show();

This is not all, in this way I need to do the query twice :|Can this also be done in one run??

below is part of the result of the above query (data does not match my example)
sc_group   sc_order   sc_cost  sc_group_combi
1   0   0   R1_regular_O1
2   2000   400   R1_package_O1
2   3000   300   R1_package_O1
2   4000   200   R1_package_O1
2   5000   100   R1_package_O1
2   6000   0   R1_package_O1
3   3000   800   R1_regular_O2
3   4000   700   R1_regular_O2

Thanks for any help!!
By: Skrol29
Date: 2004-05-24
Time: 23:47

Re: Quick help please

Hi Rwd,

Your header block doesn't work because there is (apparently) no  "test" column. And if there is, it should be column "sc_group_combi" instead.
The next parameter header is unsuseful because it is not in a block definition tag.

Here is a solution to do the same in 1 query:

HTML:
<script language="JavaScript">
function UpdateCountryInfo( objCountryId )
{
    // Pricing variables
    var scArray = new Array();
    // Groups first
    {prices;block=begin;headergrp=sc_group_combi}
    scArray[ '{prices_hdrs.sc_group_combi}' ] = new Array();
    {prices;block=end}
    {prices;block=begin}
    scArray[ '{prices.sc_group_combi}' ][ 'order' ] = {prices.sc_order};
    scArray[ '{prices.sc_group_combi}' ][ 'cost' ] = {prices.sc_cost};
    {prices;block=end}
}
</script>

PHP:
$tbs->LoadTemplate($dir['templ'] . 'coc_user_input.htm');
$tbs->MergeBlock( 'prices_hdrs', $DB->Link_ID, 'SELECT sc_group_combi , sc_order , sc_cost FROM sc, sc_group WHERE sc_group_id = sc_group ORDER BY sc_group_combi' );
$tbs->Show();
By: RwD
Date: 2004-05-25
Time: 16:10

Re: Quick help please

Can't test it where I am now, will try at home, but I don't think this literally copied will work...

You use prices_hdrs and prices both. I guess this has to be replaced by one or the other...

Thanks for the help, this will save me time at home!!!
Still don't think I'll make my deadline, I've even taken a day of for it :P perhaps I'll squeeze it through the closing door that closes at the deadline now :P

By: Skrol29
Date: 2004-05-25
Time: 17:22

Re: Quick help please

>You use prices_hdrs and prices both.
>I guess this has to be replaced by one or the other...

You're right. Sorry.
Replace prices_hdrs by prices.
The javascript code result won't look exactly the same (it will be sorted by sc_group_combi) but will do the same.
By: RwD
Date: 2004-05-25
Time: 19:43

Re: Quick help please

Great, now it works exactly as I originally intended... array declarations just above the use of it....

Thanks