0

Hello everyone,

I'm trying to combine 3 form input fields into 1 that is hidden (Date of Birth). The input fields are DOB-MM, DOB-DD, and DOB-YYYY and the hidden field is DOB which will store the Date of Birth in the following format 'YYYY-MM-DD'. Unfortunately I don't know javascript so I hope someone can help me write a quick script that will combine these 3 fields and arrange them in the format required.

Thank you in advance!

Cheers!

<form name="signup" action="{{{form_url}}}" class="appnitro" method="post" >
					<div class="form_description">
			<h2>Newsletter Sign-up</h2>
		</div>						
			<ul >
			
					<li id="li_1" >
		<label class="description" for="person_name">Name / Nombre </label>
		<span>
			<input id="person_first_name" name= "person[first_name]" class="element text" maxlength="255" size="20" value="{{{first_name}}}"/>
			<label>First Name / Nombre</label>
		</span>
		<span>
			<input id="person_last_name" name= "person[last_name]" class="element text" maxlength="255" size="20" value="{{{last_name}}}"/>
			<label>Last Name / Apellido</label>
		</span>		</li>		<li id="li_3" >
		<label class="description" for="person_email_address">Email / Correo Electronico * (Required)</label>
		<div>
			<input id="person_email_address" name="person[email_address]" class="element text medium" type="text" maxlength="255" value="{{{email_address}}}"/> 
		</div> 
		</li>		<li id="li_4" >
		<label class="description" for="person_dob">Date of Birth / Fecha de Nacimiento </label>
		<span>
			<input id="person_dobmm" name="person[dobmm]" class="element text" size="2" maxlength="2" value="{{{dobmm}}}" type="text"> /
			<label for="DOB-MM">MM</label>
		</span>
		<span>
			<input id="person_dobdd" name="person[dobdd]" class="element text" size="2" maxlength="2" value="{{{dobdd}}}" type="text"> /
			<label for="DOB-DD">DD</label>
		</span>
		<span>
	 		<input id="person_dobyyyy" name="person[dobyyyy]" class="element text" size="4" maxlength="4" value="{{{dobyyyy}}}" type="text">
			<label for="DOB-YYYY">YYYY</label>
		</span>
			<input id="person_dob" name="person[dob]" start_year="1910" type="hidden" value="{{{dob}}}" />
		</li>		
		
		<li class="buttons">
		    
				<input class="button_text" type="submit" name="commit" value="Sign Up" />
		</li>
			</ul>
		</form>

Edited by nav33n: Use [code][/code] tags to wrap your code for easy readability.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rajarajan07
0
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="javascript">
function check(){
	var text=yyyy.value+"-"+mm.value+'-'+dd.value;
	alert(dob.value);
	dob.value=text;
	alert(dob.value);
}
</script>
</head>
<body>
MM <input type="text" size="2" name="mm">
DD <input type="text" size="2" name="dd">
YY <input type="text" size="4" name="yyyy">
<input type="submit" name="commit" value="Submit" onClick="check()">
<input type="hidden" size="10" name="dob" value="test">
</body>
</html>
0

Hello RajaRajan.R,

Thank you for your reply. One quick question about your code. Should the value of the line below be test or text?

<input type="hidden" size="10" name="dob" value="test">

Regards,

TolucaDiablo

0

Dont worry about that, it is "test" only it is a default value displayed in the hidden field, you can also leave it simply with "". We change the "test" to "1998-5-12" in javascript using that name of the hidden field.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.