The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> how can I combine two input fields to send to the same database field?, html forms
supasnail
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Oct 30 2006, 10:53 PM
Post #3


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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 ....)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post 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



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jimlongo
post 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



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?

This post has been edited by jimlongo: Oct 31 2006, 02:15 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Oct 31 2006, 11:37 PM
Post #6


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post 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



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".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 09:33 PM