Announcement

Collapse
No announcement yet.

initial value of a field

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

  • initial value of a field

    Hi everybody, I have a simple query, but have been able to twist around the solution with trial and error, but I think is not reliable.

    I have a form on which all fields are read-only. Now, when I click on ADD I get a form with all new fields (none are disabled).
    What I want:
    I would like to make a field take a value like this: {year} = date('Y', strtotime( date('d-m-Y'))).
    As soon as I click on ADD this field must be initialized to the value.... in which event or any other method to go about this?

    Thanks again for fast reply.

  • #2
    I was able to put the code in onBeforeInsert ... but then it does not appear on the form while editing. onLoad is not Ok, as this will over-write the database vallue.

    Comment


    • #3
      If you already have a stored value in db why do you want to print another value date('y') ?

      Comment


      • #4
        For new record

        Comment


        • #5
          In onload add this
          Code:
          if(strlen({val_from_db})<4)
            {val_from_db}=date('Y', strtotime("now"));

          Comment


          • #6
            Hello Clauu,

            Your suggestion was smart! Thank you, it worked wonderfully.

            Comment


            • #7
              Originally posted by michael View Post
              Your suggestion was smart!
              Why coding, when you can (and should!) use Form Settings / Edit Fields / DB value (Insert)?
              Best regards: - Reinhard -

              I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

              Comment


              • #8
                Originally posted by RHS View Post
                Why coding, when you can (and should!) use Form Settings / Edit Fields / DB value (Insert)?
                You mean i can put the formula in "defined value"?

                Comment


                • #9
                  Yes, try it ...
                  Best regards: - Reinhard -

                  I use ScriptCase 8 Enterprise Edition, Version 8.(latest)

                  Comment

                  Working...
                  X