Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ how can I combine two input fields to send to the same database field?

Posted by: supasnail Oct 30 2006, 03:03 PM

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

Posted by: Darin McGrew Oct 30 2006, 03:47 PM

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.

Posted by: Brian Chandler Oct 30 2006, 10:53 PM

QUOTE(Darin McGrew @ Oct 31 2006, 05:47 AM) *

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 ....)

Posted by: Darin McGrew Oct 31 2006, 02:10 PM

QUOTE(Brian Chandler @ Oct 30 2006, 07:53 PM) *
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.

Posted by: jimlongo Oct 31 2006, 02:15 PM

QUOTE(Darin McGrew @ Oct 31 2006, 02:10 PM) *

QUOTE(Brian Chandler @ Oct 30 2006, 07:53 PM) *
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


Unless 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?

Posted by: Brian Chandler Oct 31 2006, 11:37 PM

QUOTE(jimlongo @ Nov 1 2006, 04:15 AM) *

QUOTE(Darin McGrew @ Oct 31 2006, 02:10 PM) *

QUOTE(Brian Chandler @ Oct 30 2006, 07:53 PM) *
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


Unless 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.

Posted by: Darin McGrew Nov 1 2006, 02:12 AM

QUOTE(Brian Chandler @ Oct 31 2006, 08:37 PM) *
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".

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)