473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dynamically Fill and Format a texfield box based on 2 other filled texfield boxes

I have 3 texfield boxes

1. firstname
2. lastname
3. username

When a person enters in their firstname and lastname, I want the
username field to fill with firstnameLastinitial.

Eg. Firstname = Adam, Lastname = Apple, Username = AdamA

I want to do it dynamically so as they're typing their firstname, it's
filling in the username field. And when they fill in their lastname,
it does it, but it would only have to do it for the first letter then
go out of the loop.

I don't even know where to start on this one.. onChange is the event?
:)

Any help appreciated
Ryan
Jul 20 '05 #1
2 1569

RelaxoRy <re******@postmaster.co.uk> wrote in message
news:3b**************************@posting.google.c om...
I have 3 texfield boxes

1. firstname
2. lastname
3. username

When a person enters in their firstname and lastname, I want the
username field to fill with firstnameLastinitial.

Eg. Firstname = Adam, Lastname = Apple, Username = AdamA

I want to do it dynamically so as they're typing their firstname, it's
filling in the username field. And when they fill in their lastname,
it does it, but it would only have to do it for the first letter then
go out of the loop.

I don't even know where to start on this one.. onChange is the event?
:)

Any help appreciated
Ryan


Hi Ryan,
sure sounds like this one has been done before somewhere.

The onchange version works when you're finsihed with a field and
could be as simple as

<form name="myform">
<table cols="1" width="200">
<tr><td>
First <input type="text" width="20" maxlength="20" value="" name="first"
onchange="myform.full.value=myform.first.value+' '+myform.last.value;"
/>
</td></tr>
<tr><td>
Last <input type="text" width="20" maxlength="20" value="" name="last"
onchange="myform.full.value=myform.first.value+' '+myform.last.value;"
/>
</td></tr>
<tr><td>
Full <input type="text" width="4" maxlength="40" value="" name="full"
READONLY />
</td></tr>
</table>
</form>

The more dynamic version may be a bit more involved and
will probably use HTMLElement.onkeypress for starters.
No example at this time.

Chris
Jul 20 '05 #2

"RelaxoRy" <re******@postmaster.co.uk> wrote in message
news:3b**************************@posting.google.c om...
I have 3 texfield boxes

1. firstname
2. lastname
3. username

When a person enters in their firstname and lastname, I want the
username field to fill with firstnameLastinitial.

Eg. Firstname = Adam, Lastname = Apple, Username = AdamA

I want to do it dynamically so as they're typing their firstname, it's
filling in the username field. And when they fill in their lastname,
it does it, but it would only have to do it for the first letter then
go out of the loop.

I don't even know where to start on this one.. onChange is the event?
:)

Any help appreciated
Ryan


How about this idea - using 'onkeyup'...

<html>
<head>
<title></title>
<head>
<script type="text/javascript">

function yourUserName()
{
var first = document.forms['myForm'].elements['firstname'];
var last = document.forms['myForm'].elements['lastname'];
var user = document.forms['myForm'].elements['username'];

user.value = first.value + last.value.charAt(0);
}

</script>
</head>
<body>
<form name="myForm">

<input type="text" name="firstname"
onkeyup="this.form.username.value=this.value">
<input type="text" name="lastname" onkeyup="yourUserName()">
<input type="text" name="username">

</form>
</body>
</html>

--
Geoff
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John | last post by:
Hi, we have the following problem: in our application v1.0 we have static html pages (+ some javascript). With a CMS (a Content Management System) some "mortal" people can add or expand the...
4
by: Sherwood Botsford | last post by:
Table Markers ID (Primary Key) This&That PointClass (Combo box) Points Table PointClasses PointClass (primary key) Points (number) Description (Text)
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
9
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks ...
7
by: Daniel Walzenbach | last post by:
Hello, I want to create a Word XML file based on the input users make in a VB.NET application. I imagine creating a template in Word and saving it as a XML file. I then want to fill the...
8
by: SalamElias | last post by:
I create 2 groupes of checkboxes dynamically (I don't use checkboxlist) for 2 differnet zones in my aspx web page and I assign a "onClick" javascript handler by group., lets say the first 4 chboxes...
6
by: Bjorn Sagbakken | last post by:
Hello In VS2005: I am adding buttons and textboxes dynamically into a table, that also dynamically expands. So far, so good, actually very nice. But I am having trouble starting the desired...
1
by: Kev | last post by:
Hello I have a form (RosterForm) based on a table - RosterRange RosterRange has 4 fields: RosterRangeID Autonumber RosterStartDate Date RosterEndDate Date (probably...
2
by: Dwight Johnson | last post by:
I am building a website in VS2005. I basically have one page, default.aspx, which contains placeholder objects into which I add various controls that are dynamically created. I have a dropdownlist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.