hide field based on var when insert a new record.

Hi there,

i use the following code oNscriptInit

/**

  • Hide/show a field
    */

if ($ev_conf_gesprek == ‘1’) // Display field
{
sc_field_display({ronde_naam}, ‘on’);
sc_field_display({ronde_datum}, ‘on’);
sc_field_display({ronde_start_tijd}, ‘on’);
sc_field_display({ronde_eind_tijd}, ‘on’);
sc_field_display({ronde_nr}, ‘on’);
sc_field_display({ronde_kleur}, ‘off’);
}
else if ($ev_conf_gesprek == ‘2’)
{
sc_field_display({ronde_naam}, ‘on’);
sc_field_display({ronde_datum}, ‘off’);
sc_field_display({ronde_start_tijd}, ‘off’);
sc_field_display({ronde_eind_tijd}, ‘off’);
sc_field_display({ronde_nr}, ‘on’);
sc_field_display({ronde_kleur}, ‘off’);
}
else
{
sc_field_display({ronde_naam}, ‘on’);
sc_field_display({ronde_datum}, ‘off’);
sc_field_display({ronde_start_tijd}, ‘off’);
sc_field_display({ronde_eind_tijd}, ‘off’);
sc_field_display({ronde_nr}, ‘on’);
sc_field_display({ronde_kleur}, ‘on’);
}

works fine, depending on the value it shows or hides fields. When i insert a new record, all the fields are shown but i wan’t to hide this fields also, based on the value. SO i put this code in beforeInsert. that didi’nt work…

any sugestions? Simply hiding the fields isn’t an option, because when the value is changed i want the field to be shown.

Try AjaxEvents onChange

use
[TABLE=“cellpadding: 0, cellspacing: 0”]
[TR]
[TD]sc_btn_new[/TD]
[/TR]
[TR]
[TD] [TABLE]
[TR]
[TD]Available when the “Add New” button is clicked. Can be tested and used inside the ScriptCase events, allowing especific programmation in run time.

if (sc_btn_new)
						{
						{My_Date} = date('Y/m/d');
						}

[/TD]
[/TR]
[/TABLE]
[/TD]
[/TR]
[/TABLE]

also exists with delete, update and insert. Check manual

He thanks both, this helps a lot. Funny but when you use form setting multiple fields, the script works fine.