Announcement

Collapse
No announcement yet.

Copy value from one field to second if the second in null

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

  • Copy value from one field to second if the second in null

    Hi,

    Could someone point me in the right direction. I want to copy the value to a second field in case the user leaves it blank when submitting the form.

    Any help would be appreciated.

  • #2
    Sounds like a job for Event: onBeforeUpdate/onBeforeInsert and an If then statement in PHP ...

    BR

    Eric

    Comment


    • #3
      Hey Eric,

      Thanks for the reply. Yeah, I'm going to place the code in onValidate as i'm using a Control form and it doesn't have those events. Anyhow I still trying to work out the code.

      Update:
      Here what I got:4

      if({to} = null);
      {to} = {from};

      It sort of works however its too late as the value is copied after the form is refreshed. I need to have the value there before so calculations can be performed and the value can be saved in the database.

      A partial fix is adding a ajax event. However that too fails if the user directly clicks the Add button without clicking or focusing anywhere else.

      Kind Regards,

      Imran
      Last edited by gamer99; 05-05-2014, 10:03 AM.

      Comment


      • #4
        While processing the form, the way is to use the specific ajax-event to solve that problem. In the case, that the user dircetly clicks the Add-button you need to use the normal non-ajax-event on-before-insert event to back up that.

        BR

        Eric

        Comment


        • #5
          Thanks for replying. Yes but the issue is that Control Forms don't have that event (on-before-insert)

          Comment


          • #6
            Originally posted by gamer99 View Post
            Thanks for replying. Yes but the issue is that Control Forms don't have that event (on-before-insert)

            if({to} = null);
            {to} = {from};

            This should be


            if({to} == '') {
            {to} = {from};
            }

            The null value is never accepted from php, but is a database sql issue.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              Thank you Albert. I'll make the changes.

              Comment

              Working...
              X