/    Sign up×
Community /Pin to ProfileBookmark

combine 3 form values into 1

Hi,

I have a form where dob is generated using 3 select boxes, 1 for day, month and year. My output needs to be in the form dob=dd-mm-yyyy rather than day=dd, month=mm and year=yyyy.

It has been suggested that i do the following:

“On submit button click, use JS to create a hidden input (Q5) in the form and assign its value, then disable the day, month, and year fields so they are not submitted.”

Does anyone know how to do this?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 16.2010 — 'hiding' doesn't work[CODE]<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>

<script type="text/javascript">
function formatDate(f) {
f.dob.value = f.day.value+"-"+f.month.value+"-"+f.year.value;
f.day.removeAttribute('name');
f.month.removeAttribute('name');
f.year.removeAttribute('name');
}
</script>

<style type="text/css">
* {margin:0;padding:0;}
</style>

</head>
<body>
<form action="" method="get" name="form1" onsubmit="formatDate(this);">
<input type="text" name="day" value="16">
<input type="text" name="month" value="11">
<input type="text" name="year" value="2010">
<input type="hidden" name="dob" value="">
<button type="submit">submit</button>
</form>
</body>
</html>
[/CODE]
×

Success!

Help @freeman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...