Announcement

Collapse
No announcement yet.

Update field on the fly

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

  • Update field on the fly

    Ok so I have fields {dS_Total} {mT} {tT} {wT} {thT} {fT} {sT} {suT}

    When for example {mT} is updated before the form is submitted (so on the fly) {dS_Total} will be updated with a new calculated value pulled from the other values.

    Currently I have alot of events for onChange or onFocus etc but none that I can see changes the total value {dS_Total} without it being clicked on or moused over, I was hoping that the onChange would see a change made in {mT} then update {dS_Total} without any other input from the user.

    Basically I need to have the form completed and calculated before it's commited to the database with as little input from the user as possible.

    I hope that makes sence to someone

    Thanks again

  • #2
    Originally posted by w33tbix View Post
    Ok so I have fields {dS_Total} {mT} {tT} {wT} {thT} {fT} {sT} {suT}

    When for example {mT} is updated before the form is submitted (so on the fly) {dS_Total} will be updated with a new calculated value pulled from the other values.

    Currently I have alot of events for onChange or onFocus etc but none that I can see changes the total value {dS_Total} without it being clicked on or moused over, I was hoping that the onChange would see a change made in {mT} then update {dS_Total} without any other input from the user.

    Basically I need to have the form completed and calculated before it's commited to the database with as little input from the user as possible.

    I hope that makes sence to someone

    Thanks again
    Yes, php events are triggered by a commit so you loose control to the server and your form is rebuild loosing your data. You can solve this in two ways. First you could address the data to a global so that when you reload your form it will be there and presented. The second (and better) alternative is to swich over to ajax events. Then your form will not loose focus and you will be able to show your data before submit. Creating an ajax event is similar to a php event but you need to pick the right event. Onchange will trigger on each and every keyboardclick, onblur when your field looses focus. You can use the same php for calculation, so you need to move the code to the appropiate (ajax) event.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment

    Working...
    X