Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

JavaScript alert box from AfterInsert on Grid

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

    JavaScript alert box from AfterInsert on Grid

    I have a V10 grid that creates a certificate serial number that consists of a random number and the record id. Right now, I'm loading those numbers into session variables and reloading the page in order to display the message. However, the AfterInsertRecord event has help that shows how a JavaScript alert can be sent instead. If I can get this to work, I won't have to reload the page.

    Trouble is, I don't understand the example, and my bumbling around hasn't produced an alert box.

    Currently, my code in the event (which works) is

    Code:
     
    function AfterInsertRecord as v (e as p)
    e.rv.session.ct.suffix = e.lastIdentityValue
    e.rv.session.ct.prefix = e.DataSubmitted.ct_prefix
    e.rv.session.ct.amount = e.DataSubmitted.ct_amount
    e.rv.session.ct.uuid = e.DataSubmitted.ct_uuid
    e.rv.session.ct.result = "<h4>Certificate number "+e.DataSubmitted.ct_prefix+"-"+e.lastIdentityValue+" for $"+e.DataSubmitted.ct_amount+" was successfully created</h4>"
    end function
    What I want to do is show the message in session.ct.result in the alert box. The help says:
    Code:
     
    'e also contains a pointer to the AjaxResponses array (e.rtc.A_AjaxResponses[]). 
    'To send a Javascript command to the browser, make an entry in this array.
    'Example
    ' aa = e.rtc.A_AjaxResponses
    ' aa[].text = "alert('Message');"
    ' aa[..].id = 100  'the order in which AjaxResponses are sent to the browser
    'end if
    but, my playing around with that hasn't worked.

    Anyone have a working example to share?

    Pat
    Pat Bremkamp
    MindKicks Consulting

    #2
    Re: JavaScript alert box from AfterInsert on Grid

    Pat the code in the example is incomplete it should be something like
    Code:
    if e.DataSubmitted.Desc = "" then
        e.cancel=.t.
        dim aa as p
        aa = e.rtc.A_AjaxResponses
        aa[].text = "alert('Message');"
        aa[..].id = 100  'the order in which AjaxResponses are sent to the browser
    end if
    but in your case you don't want/need to test any submitted data, so you can do away with the if...then...end if test and also e.cancel=.t. bits.

    Then you just need parse in your message from the results.

    PS I didn't know any of this an hour ago so thanks for making me learn.

    Comment


      #3
      Re: JavaScript alert box from AfterInsert on Grid

      Lance and Pat,

      I too have been having a lot of difficulty with many of these new event functions. I believe there are probably some wonderful new capabilities here - more than any of us know but some examples are needed to gain a better understanding.

      I wonder if there is a way that we could get developers to post working examples of these new events to show function and design features that would greatly benefit many of us?

      Comment


        #4
        Re: JavaScript alert box from AfterInsert on Grid

        Hi Michael,

        These new events are great and pretty simple once you get used to the terminology, which variable is available where and you realise that you can manipulate them with good old xbasic then output it in HTML. I am getting a better understanding day by day! Here is my re-working on the summary area on a grid, took about an hour to get the HTML to place everything in the correct column, now just have to add it to a few other grids that need the same treatment!

        The real power is in the javascript - system events (on the grid properties tab), there are a lot of events in there and the beauty is there is sample javascript already written for you to work around, I've got some really clever bits working by just adding parameters to the code given. It's really good and works just as I would expect!

        If there is something specific you need sorting PM me and I will attempt to look for you.

        Comment


          #5
          Re: JavaScript alert box from AfterInsert on Grid

          Lance,

          Thanks for your help. I don't have it working yet, but I'm encouraged by your success!

          Pat
          Pat Bremkamp
          MindKicks Consulting

          Comment


            #6
            Re: JavaScript alert box from AfterInsert on Grid

            Originally posted by Pat Bremkamp View Post
            Lance,

            Thanks for your help. I don't have it working yet, but I'm encouraged by your success!

            Pat
            Pat, sorry to dredge up this thread, but did you ever get this to work?

            I'm just putting

            dim aa as p
            aa = e.rtc.A_AjaxResponses
            aa[].text = "alert('Message');"
            aa[..].id = 100 'the order in which AjaxResponses are sent to the browser

            in the AfterInsert event of my grid and I can't get anything to show up in the browser. Debug shows the even is firing and aa is being loaded properly, I just don't get any message popup displayed in the browser.

            I've searched these Boards and the wiki but whatever I've found hasn't resolved this for me.

            Thanks for any info.


            Norman

            Comment


              #7
              Re: JavaScript alert box from AfterInsert on Grid

              This works for me:

              Code:
              aa = e.rtc.A_AjaxResponses
              aa[].text = "alert('The ANC was not initialed.');"
              Hope that helps.

              Comment


                #8
                Re: JavaScript alert box from AfterInsert on Grid

                Originally posted by christappan View Post
                This works for me:

                Code:
                aa = e.rtc.A_AjaxResponses
                aa[].text = "alert('The ANC was not initialed.');"
                Hope that helps.
                So you don't include the aa[..].id = 100? This is in one of the Server events in a grid? Which one? And when the app gets to these lines it throws up an alert on the browser? That sure doesn't happen for me. BTW, not trying to give you more work, the preceding questions were more rhetorical than anything. :)

                Well, I'll try it, if it doesn't work in the grid I just built I'll create an empty one and see how it goes.

                If it works for you, it's gotta work for me!

                Thanks.


                Norman

                Comment


                  #9
                  Re: JavaScript alert box from AfterInsert on Grid

                  Here's what has worked for me without fail:

                  STEP 1: Define your pointer (P) up near the top of the function, next to any other DIM statements.

                  dim aa as p
                  aa = e.rtc.A_AjaxResponses

                  STEP 2: Set any session variables if you want.

                  e.rv.Session.theSecondPopupText = "This is the text for the second popup alert box."

                  STEP 3: From anywhere in the rest of the function, simply stuff the next available aa[].text array element with a command (javascript) that you want to execute. The element "aa[..].id = x" specifies the order in which that command will be executed.

                  aa[].text = "alert('This is popup box three.')"
                  aa[..].id = 3

                  aa[].text = "alert('" + e.rv.Session.theSecondPopupText + "')"
                  aa[..].id = 2

                  aa[].text = "alert('This is popup box one. It will popup first because its id is equal to 1.')"
                  aa[..].id = 1

                  RESULT: You will see three popup boxes displayed in the following order.

                  1) "This is popup box one. It will popup first because its id is equal to 1."

                  2) "This is the text for the second popup alert box."

                  3) "This is popup box three."

                  Good luck!

                  Comment

                  Working...
                  X