Blocks are not hideing using - sc_block_display

Hello everyone,

I’m using this version of scriptcase:
Version 8.00.0030
Types pe_mysql_bronze
##############################

i made this little script:
//--------------------------------------------------------------------
if ({label} == ‘1’) // Display block
{
sc_block_display(operation_n_sdt, ‘on’);
sc_block_display(operation_sdt, ‘off’);
}
else // Hide block
{
sc_block_display(operation_n_sdt, ‘off’);
sc_block_display(operation_sdt, ‘on’);
}
//--------------------------------------------------------------------

I defined the php method - labelscript, and called it in:
on aplication init;
on navigate;
on script init;
on load;
on refresh;
on after insert;
on after update;

and i made also a ajax event for the field “label” - on change.

The bloks remains unhidenn.

Any ideea what i can do about this?

Thank you,
Dan

Nothing obviously wrong I can see. But first, a couple of “just to be sure” questions…

  • I presume this is a form (as opposed to a grid)?
  • the names operation_n_sdt and operation_sdt are defined as named blocks?

Second - 2 possibilities:

  • What is the data type of {label}? - if it’s integer / numeric then don’t wrap the 1 in quotes.
if ({label} == 1) 
  • The field {label}, is that it’s actual name? Not sure if “label” might be a reserved word so maybe try and rename the field to {label1} and change the references to match?

Partial solved :frowning:

ok, i made the changes:


  • file_label is/was integer;
  • file_label changed from label;
  • the actions takes in a form.

cod
//---------------------
if ({file_label} == 1)
{
sc_block_display(operation_std, ‘off’);
sc_block_display(operation_n_std, ‘on’);
}
else if ({file_label} == 0)
{
sc_block_display(operation_std, ‘on’);
sc_block_display(operation_n_std, ‘off’);
}

else // Hide block
{
sc_block_display(operation_n_std, ‘off’);
sc_block_display(operation_std, ‘off’);
}
//------------------------------
the last else i don’t think is necessary …but i put it anyway.

Now it is working just this area:
//---------------------------
else if ({file_label} == 0)
{
sc_block_display(operation_std, ‘on’);
sc_block_display(operation_n_std, ‘off’);
}
//--------------------------------

in this part of cod:
//--------------------------------
if ({file_label} == 1)
{
sc_block_display(operation_std, ‘off’);
sc_block_display(operation_n_std, ‘on’);
}
//---------------------------------------

I have active both bloks…

any ideea what to do?

thank you

Maybe the label values are not being set quite as you think.

What happens if you change:

else if ({file_label} == 0)

To

else if ({file_label} != 1)

If that works then {file_label} is never zero as you thought, i.e. maybe it’s NULL? In which case leave as is using NOT (!), or confirm the values to test against, and adjust accordingly.

As it looks you have only one ‘true’ value. So no need to mess around, keep it simple.

Bring both blocks to defined state at the beginning of your code.

sc_block_display(operation_std, ‘off’);
sc_block_display(operation_n_std, ‘off’);

if ({file_label} == 1)
{
sc_block_display(operation_n_std, ‘on’);
}
else
{
sc_block_display(operation_std, ‘on’);
}

Should work like a charm.

jsb

[QUOTE=jsbinca;32505]As it looks you have only one ‘true’ value. So no need to mess around, keep it simple.

Bring both blocks to defined state at the beginning of your code.

sc_block_display(operation_std, ‘off’);
sc_block_display(operation_n_std, ‘off’);

if ({file_label} == 1)
{
sc_block_display(operation_n_std, ‘on’);
}
else
{
sc_block_display(operation_std, ‘on’);
}

Should work like a charm.

jsb[/QUOTE]

Thank you, it worked :slight_smile: