Announcement

Collapse
No announcement yet.

AJAX Events onClick of Button or image?

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

  • AJAX Events onClick of Button or image?

    Is there ANY way to trigger an AJAX event on a button that is clicked, or an image that is clicked?
    I have PHP code that validates an address that is entered into text fields on a form. I can call that code when a radio button is clicked, or a checkbox is clicked, etc.... but cannot figure out a way to call that code when a button is clicked.
    There is no field type "button", and if I create a Label field and put an HTML button in it then it doesn't catch the "onClick" with an AJAX event.
    Please point me in the right direction if I am going about this all wrong.
    I am still a new Scriptcase User....
    Thanks!

  • #2
    If you need to fire code on a button you need to create a button and by doing that you choose if it will be a php type button or javascript type button. Then you get a field in which you can enter your code.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      That doesn't achieve the AJAX type result I am looking for. When I click a PHP type button it goes to an "OK" button and the page is sent to the server and back.
      The AJAX event just fires of the little bit of PHP code that I want to run and does it perfectly. I just can't get an AJAX event to fire from a button... any form type HTML element seems to let me.... RADIO, CHECKBOX, even text fields.
      Thanks for your suggestion Albert, but It doesn't produce my desired result.

      Comment


      • #4
        hey dude:

        why dont you try to use an image field, set him to a button img and use the onclick ajax event?

        Regards.

        Comment


        • #5
          If it works it would be great, but afaik the event doesn't trigger. But that might have been solved as I never used it since I reported that.
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment


          • #6
            No you are right Albert... It wont even let me create an Ajax Event for HTML Image Type of field. If it did, that would be perfect for my use!
            Thanks for the suggestions so far.... any other ideas?

            Comment


            • #7
              Well that's a solution, my report was 'fixed' by disallowing the event ;-) Seriously I can see why. But perhaps the following is a suitable solution:

              You can create a link on an image. A dirty trick I sometimes use is that I put a blank application in between and then use sc_redir to move to the desired application after doing some things. You can create a link to a blank application, even pass parameters to that if you define globals in your blank application to map your fields against.

              But I don't know if it would be helpful for you though.
              Albert Drent
              aducom software netherlands
              scriptcase partner, reseller, support and (turn-key) development
              www.scriptcase.eu / www.scriptcase.nl

              Comment


              • #8
                Well.. i can offer you something else. in your form, create a field of the type label and in the label text you can use html content such as

                <a href=[the php file to execute the code]>link</a>

                hope this helps.

                Regards

                Comment


                • #9
                  It wont even let me create an Ajax Event for HTML Image Type of field.
                  NOOR

                  Comment


                  • #10
                    I have the same problem. Why I can't make a image html onclick ajax event?

                    Comment


                    • #11
                      Don't know why, but it's not supported. It's an issues since I work with SC.
                      Albert Drent
                      aducom software netherlands
                      scriptcase partner, reseller, support and (turn-key) development
                      www.scriptcase.eu / www.scriptcase.nl

                      Comment


                      • #12
                        I doesn't matter. I solve the problem making a text input field and defined like label, then onload :

                        {start}='<a id="id_sc_field_start" class="scButton_default" style="vertical-align: middle; display:inline-block;">Start</a>';

                        then in "ajax events" start_onClick event:

                        $javascript_function = 'myStartjsFunction'; // Javascript function name
                        sc_ajax_javascript($javascript_function);

                        myphpstartfunction(); //this function insert info into db

                        Is working nice! hehehe.

                        Comment


                        • #13
                          Originally posted by apolo512 View Post
                          I doesn't matter. I solve the problem making a text input field and defined like label, then onload :

                          {start}='<a id="id_sc_field_start" class="scButton_default" style="vertical-align: middle; display:inline-block;">Start</a>';

                          then in "ajax events" start_onClick event:

                          $javascript_function = 'myStartjsFunction'; // Javascript function name
                          sc_ajax_javascript($javascript_function);

                          myphpstartfunction(); //this function insert info into db

                          Is working nice! hehehe.
                          hi apolo512
                          how you manage to add ajax event to label field?

                          Comment


                          • #14
                            well, update: i could manage to create text field and marked it from inside the filed properties to: label = Yes.
                            configuring it as image in onLoad e.g. {field}= "<img src='../_lib/img/sys_image1.png'></img>";

                            but i couldn't make it ajax -> onClick to show a block using: sc_block_display(myblock, 'on');

                            any idea how to make this work?

                            Comment

                            Working...
                            X