DotDragnet
February 07, 2012, 01:15:54 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: follow us on twitter @dotdragnet
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: jquery copy form data once  (Read 691 times)
sarahA
DDN Contribs
Hero Member
*****
Posts: 2123



View Profile WWW Awards
« on: August 23, 2010, 02:36:16 PM »

Currently working on a form which has two parts, outward and return (for journeys). You can choose to have either or both. When you first go to the page it simply says 'do you require an outward journey', and 'do you require a return journey', with a checkbox for each. So checking the outward one then displays the form for the outward journey details.

With me so far...? wink

So, if someone wants both an outward and return, most of the time their return journey details are going to be the same, but in reverse of the outward one. ie. the outward's destination will be the return's pickup, the outward's pickup will be the return's destination. Think of going to a pub in a taxi and then getting picked up and going back to where you started.

Therefore my assumption is, people are not going to want to have to fill out the same details twice. They complete the outward journey section, and then tick to say yes they want a return journey, and ideally when the return journey form displays it has the pickup point, destination a couple of other fields copied over from the outward one. This I can do.

However... how can I ensure that it only happens once? eg. if the visitor clicks to say yes they want a return journey, but actually they want to go elsewhere so they change the destination. Then cleverly they untick the 'I want a return journey' box. Realise what they've done and tick it again. I know I wouldn't be happy if my change had been lost and I had to do it again!

So, basically how can I ensure I only copy the form data over once, on the first time they say they want a return journey?

Sorry for waffling... I do that a lot big grin

tia.
Logged

samhs
Administrator
Hero Member
*****
Posts: 1669



View Profile WWW Awards
« Reply #1 on: August 23, 2010, 03:19:21 PM »

if ($("#return-start").val()=='') {
  // set the return start value to be the same as the outward-end value
}

If the user then unticks the box store the data in a variable in case they retick the box, or just set a flag to say you've done it already.
Logged

Loose adj a not held together; not fastened or firmly fixed in place
Lose verb to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog: www.ohwrite.co.uk
Twitter: www.twitter.com/samhs
sarahA
DDN Contribs
Hero Member
*****
Posts: 2123



View Profile WWW Awards
« Reply #2 on: August 23, 2010, 03:34:33 PM »

ahh so simple big grin

Thanks Sam
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!