Announcement

Collapse
No announcement yet.

Cannot hide fields using ajax_onclick

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

  • Cannot hide fields using ajax_onclick

    What am I doing wrong here? Just a simple ajax to hide some fields and its not working!


    Code:
    if ({employ_current} == 'Yes')     // Display field
    {
        echo 'show';
        sc_field_display({employ_type}, 'off');
        sc_field_display({employ_employer}, 'on');
        sc_field_display({employ_position}, 'on');
        sc_field_display({employ_practice}, 'on');
        sc_field_display({employ_worknature}, 'on');
    }
    else      // Hide field
    {
        echo 'hide';
        sc_field_display({employ_type}, 'off');
        sc_field_display({employ_employer}, 'off');
        sc_field_display({employ_position}, 'off');
        sc_field_display({employ_practice}, 'off');
        sc_field_display({employ_worknature}, 'off');
    }


    Screen Shot 2019-01-09 at 6.21.07 pm.png

    Screen Shot 2019-01-09 at 6.20.08 pm.png
    Screen Shot 2019-01-09 at 6.19.37 pm.png



    Attached Files

  • #2
    Hallo,

    as far as I see, you cannot use this macro in Ajax (ajaxOnClick). Online Help shows a scope without Ajax:

    Unbenannt.JPG

    Hint:
    Maybe you should use a short JavaScript to hide the field.

    Sincerely
    Gunter Eibl
    email@GunterEibl.de

    asdw.de - Scriptcase & Open Source projects (German/English)
    scriptcase.coach - professional coaching for Scriptcase users (German)
    GunterEibl.de - About me (German)

    Comment


    • #3
      Thanks for the reply!

      Do you know if maybe this has this changed recently? I am certain I have used this function before in old projects, and yesterday while troubleshooting I found this document from Scriptcase which clearly shows that it should work.

      https://support.scriptcase.net/es/ar...-an-ajax-event

      Comment


      • #4
        Just a bloody typo! Field name doesn't match the field name in the code. No error thrown, thanks a lot SC!

        Comment


        • #5
          Sorry, has nothing to do with SC, but php. Variables are declared on the fly.
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment


          • #6
            Originally posted by aducom View Post
            Sorry, has nothing to do with SC, but php. Variables are declared on the fly.
            So why did PHP stop processing on the first function call that contained an invalid field name? It should have just kept going and correctly hidden the subsequent fields. However it seems like it caught an error (didn't display it) and then silently died.

            Comment

            Working...
            X