Greetings fellow scriptcase users
I have a slight problem when using the form events and have no idea why the incorrect event is firing when not needed, soooo am hoping somebody can help…
I have two events one onclick and one onchange and also hiding specific fields on scriptinit.
AJAX onclick event:
{mbrDatePaid} = date('Y-m-d');
// Check for record
$check_sql = "SELECT mbrTypeDuration"
. " FROM mbrType"
. " WHERE mbrtypeID = '" . {mbrType} . "'";
sc_lookup(rs, $check_sql);
if (isset({rs[0][0]})) // Row found
{
$dur = {rs[0][0]};
$newdate = date('Y-m-d', strtotime("+".$dur." days"));
{mbrDateValid} = $newdate;
}
else // No row found
{
}
AJAX onchange event:
if ({mbrType} == '') // Display field
{
sc_field_display({mbrPaid}, 'off');
sc_field_display({mbrDatePaid}, 'off');
sc_field_display({mbrDateValid}, 'off');
sc_field_display({payment_amount}, 'off');
}
else // Hide field
{
sc_field_display({mbrPaid}, 'on');
sc_field_display({mbrDatePaid}, 'on');
sc_field_display({mbrDateValid}, 'on');
sc_field_display({payment_amount}, 'on');
}
// Check for record
$check_sql = "SELECT mbrTypePrice"
. " FROM mbrType"
. " WHERE mbrtypeID = '" . {mbrType} . "'";
sc_lookup(rs, $check_sql);
if (isset({rs[0][0]})) // Row found
{
{payment_amount} = {rs[0][0]};
}
else // No row found
{
{payment_amount} = '0';
}
if ({mbrType} == '') // Display field
{
{mbrDatePaid} = '00/00/000';
{mbrDateValid} = '00/00/000';
{mbrPaid} = '0';
}
else // Hide field
{
}
onscript init I am hiding the following fields:
sc_field_display({mbrPaid}, ‘off’);
sc_field_display({mbrDatePaid}, ‘off’);
sc_field_display({mbrDateValid}, ‘off’);
sc_field_display({payment_amount}, ‘off’);
now the problem I am having is that when I make a selection the onchange event fires correctly and displays the hidden fields,
but when I click the mbrPaid field and the onclick event fires it also hides the fields specified in the onscriptinit…
which in short it shouldnt, its not added to the onclick event yet it is still hiding the fields.
Any ideas if this is a problem with my above coding or is this a bug?
Thanks in advance