SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    copying data from one field to another in same form

    I have a php contact form which has fields for both invoice address and delivery address. Obviously these will very often be the same so I want to offer the customer the option of auto filling in the delivery address from the data they have inserted into the invoice address. I can do this with a javascript and onclick() but the spec I have been given forbids the use of javascript so it has to be done using php. Can anyone help?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just supply a checkbox for them to tick. If it's checked, your php knows to use the data for both. Or even just tell them to leave the second set of fields blank if the data is the same.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't use JS because my boss has NoScript always turned on and reckons that lots of other people do as well or do not allow javascript in their browsers so he has written the spec to have no javascript!! Well, I can use JS for copying data from one field to another for those who don't disallow JS but there must also be a php method to do this! So I have no choice

  4. #4
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well submit form,
    save it content to the session
    do a Location redirect to self page
    then fill form from session
    and use invoice address data to fill delivery address data

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easiest option would probably be the checkbox method - then on your form handler page you can have
    PHP Code:
    $postadd $_POST["postadd"];
    if(isset(
    $_POST["usesameadd"])) $deliveryadd $postadd; else $deliveryadd $_POST["deliveryadd"]; 
    or something along those lines
    If you don't use javascript then that's probably the only way to do it without reloading the page.
    What you could maybe do is use the checkbox method and also use javascript to fill in the del address field when the checkbox is checked just to reassure the customer that the same address is being used.

  6. #6
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    well submit form,
    save it content to the session
    do a Location redirect to self page
    then fill form from session
    and use invoice address data to fill delivery address data
    Additionally, There must be an checkbox or radio button option for "Invoice address same as delivery address"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •