how can I combine two input fields to send to the same database field?, html forms |
how can I combine two input fields to send to the same database field?, html forms |
supasnail |
Oct 30 2006, 03:03 PM
Post
#1
|
Group: Members Posts: 3 Joined: 30-October 06 Member No.: 625 |
I am wondering if this is now possible now that i've been googling for ages, but someone might know the easy answer ...
What I would like to do is allow two or more input fields in a form to be combined and sent into the same database field...., for example, rather than allow users to insert the date in any format they choose, I'd like to steer them to inserting it YYYY-MM-DD, ideally i'd like this to be in the form of three separate input boxes but I don't want three fields in the database, just the one. Is there a way to do this with simple xHTML? or will this be a javascript combo? I'm sure it can be done. Hope I have been clear enough.. Thanks |
Darin McGrew |
Oct 30 2006, 03:47 PM
Post
#2
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
You'll need to have the server-side program that processes the form data combine the three fields into a single value, and then store that single value.
But I recommend against this approach. It's annoying to have to enter data like that in pieces, especially when I could copy-paste the data if it were a single field. |
Brian Chandler |
Oct 30 2006, 10:53 PM
Post
#3
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
You'll need to have the server-side program that processes the form data combine the three fields into a single value, and then store that single value. But I recommend against this approach. It's annoying to have to enter data like that in pieces, especially when I could copy-paste the data if it were a single field. It may be "convenient" to be able to paste "4/5/6" into a date field, but then there's the eternal question of What it Means... (I remember sitting in a bar in Tokyo the day it was 5-4-3-2-1 ....) |
Darin McGrew |
Oct 31 2006, 02:10 PM
Post
#4
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
It may be "convenient" to be able to paste "4/5/6" into a date field, but then there's the eternal question of What it Means... I wouldn't paste "4/5/6" into a date field, but I might paste "2006/04/05" into a date field, or "800/123-4567" into a telephone number field, or "123 Main Street #45" into an address field, or "N 37° 24.567 W 122° 04.567" into a coodinates field. These are all examples of the kind of data that I can easily copy-paste all at once, except when forms require me to break it up into pieces and type each piece separately. |
jimlongo |
Oct 31 2006, 02:15 PM
Post
#5
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
It may be "convenient" to be able to paste "4/5/6" into a date field, but then there's the eternal question of What it Means... I wouldn't paste "4/5/6" into a date field, but I might paste "2006/04/05" into a date fieldUnless you're in the UK where you might more likely paste 2006/05/04 for the 5th of april 2006, how's the database to know? This post has been edited by jimlongo: Oct 31 2006, 02:15 PM |
Brian Chandler |
Oct 31 2006, 11:37 PM
Post
#6
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
It may be "convenient" to be able to paste "4/5/6" into a date field, but then there's the eternal question of What it Means... I wouldn't paste "4/5/6" into a date field, but I might paste "2006/04/05" into a date fieldUnless you're in the UK where you might more likely paste 2006/05/04 for the 5th of april 2006, how's the database to know? Because YYYY/DD/MM isn't any format, Bigendian, LittleEndian, or Americian. It may be fine for Darin, who may indeed have worked out how to paste an disambiguable string, but it's no good for the website, because there's nothing to stop all the other people pasting 6/5/4 in. |
Darin McGrew |
Nov 1 2006, 02:12 AM
Post
#7
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
It may be fine for Darin, who may indeed have worked out how to paste an disambiguable string, but it's no good for the website, because there's nothing to stop all the other people pasting 6/5/4 in. It seems to work fine at my credit union's online banking site. The date fields take input in the YYYY/MM/DD format, which can be typed or copy-pasted without difficulty. Or you can use the JavaScript widget, which pops up a calendar so you can click on the date you want, automatically filling in the correct YYYY/MM/DD date. Or you can leave the default value (usually the earliest possible date for the specified transaction).But ultimately, what prevents people from entering nonsense like "6/5/4" is the same thing that prevents people from entering nonsense like "2006/02/31" or like "asdfjkl". |
Lo-Fi Version | Time is now: 28th March 2024 - 09:33 PM |