Announcement

Collapse
No announcement yet.

[SOLVED] Problem with event or bug??

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] Problem with event or bug??

    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:
    Code:
    {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:
    Code:
    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

  • #2
    Well, I have some form with a lot of events too and had trouble getting it right. Does it work if you move your scriptinit procedure to the onload?
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      solved.... thx Albert!

      Was weird because when I placed the hide fields into onload intitialy it didnt hide the fields, so I moved them to the onscriptinit, and then started adding the event triggers.
      Weird but now its fine

      Thanx again Albert!

      Comment


      • #4
        I think that your browser cache was fooling you. But it's great that it works now.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment

        Working...
        X