NetTalk Central

Author Topic: Copying fields in a WebForm via a button?  (Read 3862 times)

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Copying fields in a WebForm via a button?
« on: April 10, 2012, 08:42:57 PM »
Is there a quick and easy way within a webform to have a button on screen that can copy the information from one or more fields to another?

A good example is on a shopping cart checkout form for example, where you can copy the billing address to the shipping address etc.

I tried putting code within the [On Change] section (under the 'Server Code' button) in the 'Client-Side' options of the button, and ran code to copy the database fields from one to the other, then also setup the 'Reset' fields on the button to be the destination fields, but nothing happens.

Have I missed something?

Thanks!

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Copying fields in a WebForm via a button?
« Reply #1 on: April 10, 2012, 09:13:10 PM »
Hi Devan,

I'd do it just like any other field update;

a) in the "server code" section for the button (ie Validate::fieldname routine)
p_web.SSV('dest',p_web.GSV('source'))

b) then add dest as a "reset field" to the button.

As always, remember to use session variables.

cheers
Bruce


Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: Copying fields in a WebForm via a button?
« Reply #2 on: April 10, 2012, 09:14:52 PM »
Ok, I am doing REALLY well today in the "Answer your own stupid questions" department!!  :P

It turns out in the source code to assign the values, I was doing a straight:

FLD:DestField = FLD:OrigField

instead of:

p_web.SSV('FLD:DestField', p_web.GSV('FLD:OrigField'))

Extreme fatigue == Rookie mistakes!  ::)

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: Copying fields in a WebForm via a button?
« Reply #3 on: April 10, 2012, 09:16:21 PM »

As always, remember to use session variables.




Haha Bruce - we typed our replies at the same time... Yes, I made the classic rookie error of using the database fields instead of the session variables.  All works great now! :)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Copying fields in a WebForm via a button?
« Reply #4 on: April 10, 2012, 10:39:55 PM »
ahh - you pesky Australians...

Tip: always remember to take _both_ hands off the beer while programming Devan <bg>

Cheers
Bruce