Forums

[Solved] Use two fields as Dynamic From Name in email

WhiteLighter01 20 Jan, 2012
Hi all,

I'm using chronoforms v3.2. On my form I have two fields fname and lname. I would like to use those two fields as the value for the Dynamic From Name for the email. I am able to get it to work using just one field but not with two fields.

I have tried putting a hidden field and using a javascript to populate the value of the hidden field using onChange on fname and lname. Using the hidden field as the Dynamic From Name for the email produced a weird result. The name that is appearing on the email is "Apache" from [email]apache@domainname.com[/email]. Please see code below

fname and lname
<input type="text" size="35" id="fname" name="fname" value="" onchange="fullName()" />
<input type="text" size="35" id="lname" name="lname" value="" onchange="fullName()" />


hidden field
<input type="hidden" name="completename" id="completename" value=""/>


JavaScript
function fullName(){
	firstName = document.getElementById("fname").value;
	lastName = document.getElementById("lname").value;
	document.getElementById("completename").value = firstName + ' ' + lastName;
};


Not sure what I'm doing wrong here and wuld greatly appreciate any help.

Thanks
This topic is locked and no more replies can be posted.