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 set default value for web input field?

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

    How to set default value for web input field?

    I have a date and a time field that I would like to default to today's date and time.

    I'm using a web grid to add new records and this grid is loaded on a regular A5W page.

    How do I set today's date and time (2 fields) on data that may or may not be altered by the user during the ADDING of a new record (to speed input).

    Hint: Setting default in "field rules" does not work for the web components.

    #2
    Re: How to set default value for web input field?

    Tom I had a need for the same thing, and here's how I did it -

    In the Events Section, click on "BeforeValidateNewRecords," or "CanUpdateRecord" depending on your situation, and insert the following code in place of what's in there now:
    -----------------------------------------------------------------------

    function BeforeValidateNewRecords as v (DataSubmitted as P, Args as p, PageVariables as p)
    with PageVariables
    DataSubmitted.DateEntered=date()
    DataSubmitted.TimeEntered=time()
    end with
    end function

    -------------------------------------------------------------------------
    My date field is called "DateEntered," and my time field is called "TimeEntered." My time field is just a character field, 9 wide.

    You should know of course, that this date and time will not show up until the Submit button has been pushed. Others have expressed a need to have the two fields pre-populated with the current date and time as soon as the form is opened, and as far as I know, there has been no known (or at least easy) method of doing that.

    By the way, there are a few field rules that do work with the WAS (after the submit button has been pushed), such as incremental numbering, and numeric calculations, but for the most part you're right, they do not work in web applications.
    Last edited by Rich Hartnett; 12-07-2007, 05:13 AM.
    Sergeant Richard Hartnett
    Hyattsville City Police Department
    Maryland

    Comment


      #3
      Re: How to set default value for web input field?

      Originally posted by Rich Hartnett View Post
      Tom I had a need for the same thing, and here's how I did it -
      Rich,

      Thanks for the input. Since my original post I actually implemented something almost exactly like what you suggested.

      My desire however was to have the fields "prepopulated" so that the data entry person would know that those values were already there YET they could change them if need-be.

      This would appear to be such a desirous feature I hope the gang at Alpha have taken notice and might include it in their next release.

      Comment


        #4
        Re: How to set default value for web input field?

        Yes having them populated "in advance" is what a lot of developers have been trying to make them so, but I didn't think anyone have figured out how to do it, at least not in a grid.

        Did you come up with some way to do that??
        Sergeant Richard Hartnett
        Hyattsville City Police Department
        Maryland

        Comment


          #5
          Re: How to set default value for web input field?

          Originally posted by Rich Hartnett View Post
          Yes having them populated "in advance" is what a lot of developers have been trying to make them so, but I didn't think anyone have figured out how to do it, at least not in a grid.

          Did you come up with some way to do that??
          Nope! No such luck on my part. For Alpha, the grid simply needs a field by field "initial value" property. Then that value can become part of the Input tag's "value=" attribute. I mean they are already "building" the HTML for the rest of the tag, I can't imagine that adding another attribute would be a real technical leap.

          Comment


            #6
            Re: How to set default value for web input field?

            I'm pretty sure I read on a prior posting that it can be done in a dialog component, but not in a grid. I suppose if you were well versed in java, you could add in some script that would pull that information from the client's computer and fill it in on the front end via the browser, but that's over my head, and I'm not sure how that would play out with different time zones anyway.

            I DO wish there was an easy way to do that though.
            Sergeant Richard Hartnett
            Hyattsville City Police Department
            Maryland

            Comment


              #7
              Re: How to set default value for web input field?

              FYI Tom, this is from the Alpha Five Help Manual entitled:

              Setting Grid Control Properties

              Select each field in the Selected Fields list to display its Field Properties menu. There are many optional properties for each field's control. The default values for these properties produce a useable starting configuration for your grid. This means that you can largely ignore these optional properties when you are learning to build grids or you expect to gradually refine your design in later revisions.

              Note : It is not possible to display a default value for a field in a grid's new record row. However, you can insert a default value if the user leaves the field blank by inserting a script into the grid's BeforeValidateNewRecords event.

              :(
              Sergeant Richard Hartnett
              Hyattsville City Police Department
              Maryland

              Comment


                #8
                Re: How to set default value for web input field?

                After some careful thinking I came up with a "theoritical" way in which to accomplish the default value scenario.

                We could actually create a new record "behind the scenes" and store the values into whatever fields you want. THEN, display that newly created record to the user with all the rest of the empty fields awaiting input. Of course the fields with the default values could also be displayed at this time.

                To the user, he/she never sees the "trickery" going on. I've not done this yet, but in theory it should work.

                Comment


                  #9
                  Re: How to set default value for web input field?

                  Well if you can get it to work, I'd be eager to see how you did it!!

                  I have a need for the exact same thing right now.
                  Sergeant Richard Hartnett
                  Hyattsville City Police Department
                  Maryland

                  Comment


                    #10
                    Re: How to set default value for web input field?

                    Tom, I have run into the same problem. I had thought about what you are trying to do behind the scenes. However, Depending on your code, you may wind up with a bunch of blank records. The person may go to the page to enter the info but then decide not to enter anything in and BINGO you have a blank record other than the time and date.

                    Comment


                      #11
                      Re: How to set default value for web input field?

                      Tom,

                      Phil would be correct. You could however add a query before entering the new record with the default value. Query your table to see if there are any records where the field you are storing your default value is not blank, but all other fields are blank. If there are any, then fetch the first matching record, change your default value in the field for what you would need it to be with the current date, and then load your form with that record in edit mode. If there are no matching records, then proceed with creating the new record before loading the form.

                      This would require a lot more programming behind the scenes, not sure if there would be any noticeable time differences in load time, but it may be worth it.
                      Cheryl
                      #1 Designs By Pagecrazy
                      http://pagecrazy.com/

                      Comment


                        #12
                        Re: How to set default value for web input field?

                        Thanks all for your comments. Ultimately, I think the real solution needs to come from Alpha. I have since needed to move on and tackle some other perplexing problems. This problem will, however remain at the top of my list to find a viable workaround.

                        The depressing thing is that this problem is a five minute programming task in my native ASP. I've spent 10 times that amount of time trying to find a A5 solution. So therefore while A5 can offer some real efficient code generation in many repects, it still presents some real roadblocks in other areas.

                        Like life itself, it's a matter of tradeoffs.

                        Comment


                          #13
                          Re: How to set default value for web input field?

                          Here's one way to do it.

                          I put a grid with an alias "MyGrid" on a page. The grid contains a date field named "Date_Created".

                          When the grid is published, and you look at the source, you'll find snippets of of html that look like this in the new record lines:

                          Code:
                          DATE_CREATED" value=""
                          What you want to do, of course, is insert a value so it's not blank.

                          Here's the Xbasic code on the A5W page. Make sure it's after the component is loaded but before the string is dumped into the page.

                          Code:
                          <%A5
                          ' Define the string to be modified:
                          findstr = <<%a%
                          DATE_CREATED" value=""%a%
                          
                          ' Define the modified string:
                          replacestr =<<%a%
                          DATE_CREATED" value="%a%
                          replacestr = replacestr + dtoc(date())
                          replacestr = replacestr + <<%a%
                          "%a%
                          
                          ' Use stritran() to insert the replacement value:
                          x_MyGrid.Output.Body.Grid_HTML = stritran(x_MyGrid.Output.Body.Grid_HTML, findstr, replacestr)
                          %>

                          The result is new records with today's date as the default. This isn't all that difficult. I and several others use this technique a lot to fill in holes where yeah, it would be nice if Alpha gave use the gui, but we still need to do this anyway.
                          -Steve
                          sigpic

                          Comment


                            #14
                            Re: How to set default value for web input field?

                            Tom,

                            The depressing thing is that this problem is a five minute programming task in my native ASP. I've spent 10 times that amount of time trying to find a A5 solution. So therefore while A5 can offer some real efficient code generation in many repects, it still presents some real roadblocks in other areas.
                            Inevitable frustration when learning a language I think...but the more time that passes with people creating web based Apps the easier it will be to find these types of answers on this messageboard...so I thank you for presenting this for when I end up having to try and do exactly as you are later on! A simple search now for "default value" should result in this thread coming up.

                            You say you could do this in five minutes in ASP...and I do not doubt it. Consider this now that (hopefully) a solution has been given. I, and others, could most likely do this in Alpha in five minutes but those of us who do not know ASP it most likely would take 10 times longer to do in that language!
                            Mike
                            __________________________________________
                            It is only when we forget all our learning that we begin to know.
                            It's not what you look at that matters, it's what you see.
                            Henry David Thoreau
                            __________________________________________



                            Comment


                              #15
                              Re: How to set default value for web input field?

                              Originally posted by Steve Workings View Post
                              Here's one way to do it.

                              I put a grid with an alias "MyGrid" on a page. The grid contains a date field named "Date_Created".

                              When the grid is published, and you look at the source, you'll find snippets of of html that look like this in the new record lines:

                              Code:
                              DATE_CREATED" value=""
                              What you want to do, of course, is insert a value so it's not blank.

                              Here's the Xbasic code on the A5W page. Make sure it's after the component is loaded but before the string is dumped into the page.

                              Code:
                              <%A5
                              ' Define the string to be modified:
                              findstr = <<%a%
                              DATE_CREATED" value=""%a%
                              
                              ' Define the modified string:
                              replacestr =<<%a%
                              DATE_CREATED" value="%a%
                              replacestr = replacestr + dtoc(date())
                              replacestr = replacestr + <<%a%
                              "%a%
                              
                              ' Use stritran() to insert the replacement value:
                              x_MyGrid.Output.Body.Grid_HTML = stritran(x_MyGrid.Output.Body.Grid_HTML, findstr, replacestr)
                              %>

                              The result is new records with today's date as the default. This isn't all that difficult. I and several others use this technique a lot to fill in holes where yeah, it would be nice if Alpha gave use the gui, but we still need to do this anyway.

                              Steve,

                              My hat off to you for your elegant solution to this problem. The code also brings to mind how such an implementation could be used to solve other potential problems.

                              Just one final word (question) on this issue. If you needed to set defaults for several fields, would you have to initiate several stritran() functions to solve it.

                              Tom

                              Tom

                              Comment

                              Working...
                              X