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

How to use javascript "Prompt box" to get user to input data for a field on a grid?

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

    How to use javascript "Prompt box" to get user to input data for a field on a grid?

    I love all the helpful examples I have seen and been using with Java-script to recall, lookup, add data etc.

    I an now trying to figure out how to use a JavaScript Prompt Box to work with the Inline-JavaScript function to take the input from the user and save it to a field.

    As I understand the basic java-script Prompt script is something like this, but this gives errors:
    Code:
    var name = prompt("What is your name", "Type you name here");
    alert("Hi " + name + "\nHope you are enjoying JavaScript!");
    What I really want is that if a client checks the "Canceled" check box to be "True", then an alert pops up and says, "Are you sure you want to cancel this patient?"

    If yes, then they would need to enter a short reason as to why into a pop up prompt that would follow.

    Then a prompt input box would either saved the entry into a field called "why_canceled" or returned unchanged it they opt out.

    (this is for a patient scheduling module so I want to force the client to record why a patient was canceled)

    I know this is but a few lines of JavaScript and would be a very cool feature to add to my database if someone can help show me the way! Thanks.

    #2
    Re: How to use javascript "Prompt box" to get user to input data for a field on a gri

    Try using a single quote (') and all of the standard Javascript alert/prompt boxes will work as expected.

    You will need to use the canRowDelete or canDetailViewDeleteRecord events. Your conditional logic can pop up a Javascript alert box or you can use the A5.msgBox.show() function, see info from What's new in V10 below. You could also do this elegantly with a number of third party Javascript libraries but that is a detailed discussion.

    A5.msgBox.show(title,html,type,onClose)

    This fuction can be used to display a message box in the HTML that is done entirely in Javascript and HTML meaning that you can present the user with a customized HTML message. The 'title' contains the title HTML text to display on the message box. 'html' contains the HTML to display in the body of the message box. The 'type' is a flag to tell the message box what buttons to display. The values for this flag are:

    * "o" - "OK" button.
    * "oc" - "OK" and "Cancel" buttons.
    * "yn" - "Yes" and "No" buttons.
    * "ync" - "Yes", "No" and "Cancel" buttons.
    * "none" - no buttons.

    The 'onClose' argument is a Javascript function that will be called when the user closes the message box. This function will be passed a string containing the value of the button the user pressed ("ok", "yes", "no", or "cancel"). ed ("ok", "yes", "no", or "cancel").

    Example
    Code:
    A5.msgBox.show('Save','Do you wish to save.','ync',function(button){
        if(button == 'yes'){
            // code to save...
        } else if(button == 'no'){
            // code to close without saving...
        }
    );
    If they say no just return false; from this function and that will cancel the delete.

    If they say yes and you want to add a new record to a table with a delete history, you are going to have to use an Ajax callback function or I imagine you could fire an event on a hidden row button that would add a record to a delete history table (but this could get tricky because of the asynchronous nature of Javascript).

    In any case you would want to save whatever field values you might want to record (other than session vars) as Javascript vars which you can later reference in the afterRowDelete or afterDetailViewDeleteRecord event. Then just return from the function. That will delete the record and you can record the activity in the afterRowDelete or afterDetailViewDeleteRecord event with the Ajax callback or a simulated button event( on a different row, because the original row is now history ... yikes ... use an ajax callback!).

    Sounds harder to do than it is. May make a nice instructional video ... I'll add the idea to the list.
    Bob Moore


    Comment


      #3
      Re: How to use javascript "Prompt box" to get user to input data for a field on a gri

      Wow Bob - you gave this one some thought! Thanks.

      I would imagine that "your list" is turning into a full time job . . . . but for what ever it is worth I am sure I speak for many on this forum; your help with the JavaScript has been wonderful and I know many are benefiting.

      I will play with this and report back.

      Thank you again for all your help. Mike

      Comment


        #4
        Re: How to use javascript "Prompt box" to get user to input data for a field on a gri

        OK, this was easier than I thought.

        Here is the code that I am running - it is working well:

        Code:
        // Ceate a variable - vCancelled, with the value of field 'CANCELLED'
        vCancelled={grid.Object}._getValue('G','CANCELLED',1); 
        
        // If the field 'CANCELLED' is  True, then create a variable - vWhy_Cancelled, to accept the data the user enters into the prompt
        if (
        vCancelled=='Yes'){
        var vWhy_Cancelled = prompt('Please enter a short comment as to why this case is cancelled.' + '\n' +'(such as: rescheduled, no-show, etc.)', 'Type the reason for the cancelled case here');
        
        // If the field 'CANCELLED' is  True and the user clicks OK on the prompt box, then set the grid field Why_Cancelled with the value of the variable, vWhy_Cancelled.
        // Otherwise return false
        {grid.Object}._setValue('G','WHY_CANCELLED',1,vWhy_Cancelled);
        return false;
        }
        On my grid I have a drop down box called "Cancelled" with two choices, Yes and No. On the Javascript onChange properties, I am using the code above. So if the drop down box goes from Yes to No, nothing happens. If it goes from No to yes then it all fires and writes the reason for canceling into the grid field "Why_Cancelled"

        I have this same setup of for Delete.

        Because these are patient's records I don't want anyone to have the ability to delete or cancel a patient's record permanently. Rather, I filter the views to not include any record with "Cancelled" or "Deleted" marked as True. In doing so I preserve the entire record and all the associated links yet the client will think they removed the record from the database. Plus, this way I don't have to worry about re-creating all this data to a new record to track such events. I am also recording the user and time-stamp for each of these changes.

        It all is working great! Thanks again Bob.

        Comment

        Working...
        X