Forums
This topic is locked
Combine Form Fields
Posted 09 Mar 2004 18:27:41
1
has voted
09 Mar 2004 18:27:41 colin hart posted:
I have a form that I made where the user creates a username and password. the form ask for the visitors firstname, lastname and password. I want to have another field on there for username but have it auto populate with the first letter of the firstname followed by the lastname. i.e. Bob Barker, then the username should be bbarker.any suggestions
Replies
Replied 10 Mar 2004 03:32:00
10 Mar 2004 03:32:00 Phil Shevlin replied:
Javascript
<pre id=code><font face=courier size=2 id=code>
<script language="JavaScript" type="text/JavaScript">
function setUsername() {
var fname = document.form1.firstname.value;
var lname = document.form1.lastname.value;
var uname = fname.charAt(0) + lname;
document.form1.username.value = uname.toLowerCase();
}
</script>
<form name="form1" method="post" action="">
<input name="firstname" type="text" id="firstname">
<input name="lastname" type="text" id="lastname" onBlur="setUsername();">
<input name="username" type="text" id="username">
</form
</font id=code></pre id=code>
might not be the most efficient way, but should be understandable.
<pre id=code><font face=courier size=2 id=code>
<script language="JavaScript" type="text/JavaScript">
function setUsername() {
var fname = document.form1.firstname.value;
var lname = document.form1.lastname.value;
var uname = fname.charAt(0) + lname;
document.form1.username.value = uname.toLowerCase();
}
</script>
<form name="form1" method="post" action="">
<input name="firstname" type="text" id="firstname">
<input name="lastname" type="text" id="lastname" onBlur="setUsername();">
<input name="username" type="text" id="username">
</form
</font id=code></pre id=code>
might not be the most efficient way, but should be understandable.
Replied 10 Mar 2004 19:57:34
10 Mar 2004 19:57:34 colin hart replied:
AWESOME
thanks
thanks