473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 firstnameLastin itial.

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 1593

RelaxoRy <re******@postm aster.co.uk> wrote in message
news:3b******** *************** ***@posting.goo gle.com...
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 firstnameLastin itial.

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="myfor m.full.value=my form.first.valu e+' '+myform.last.v alue;"
/>
</td></tr>
<tr><td>
Last <input type="text" width="20" maxlength="20" value="" name="last"
onchange="myfor m.full.value=my form.first.valu e+' '+myform.last.v alue;"
/>
</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.onk eypress for starters.
No example at this time.

Chris
Jul 20 '05 #2

"RelaxoRy" <re******@postm aster.co.uk> wrote in message
news:3b******** *************** ***@posting.goo gle.com...
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 firstnameLastin itial.

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.char At(0);
}

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

<input type="text" name="firstname "
onkeyup="this.f orm.username.va lue=this.value" >
<input type="text" name="lastname" onkeyup="yourUs erName()">
<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
2900
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 available images for the start site. The site loads randomly an image or a Flash animation (if the flash plugin is present) through a javascript and each time the start site loades and displays only 1 different picture. At the moment the name of...
4
4704
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
4307
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 button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
9
3066
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 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Declare your object variables
7
4988
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 template (in my application) based on the user input. When the document gets opened there should be fields users can change but others should be prevented from beeing changed (I know that an "open" file format like XML can always be modified to allow...
8
1636
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 have evHandler1 and the other 4 chboxes have evHandler2 Of course each checkbox has an id and name which comes from DB lookup tables. At the top of each group, there is a special checkbox, if checked by the user, I need to write a javascript...
6
1486
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 subroutine on postback. To me it seems like the button click event looks for a client script instead of going to the aspx codepage and execute the sub there. The same thing happens with textboxes, where I programatically add
1
2186
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 unnecessary) Ward Text I have 2 unbound combo boxes looking up values - cmbDepartment and
2
1387
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 that is created in the InitializeComponent event so I can do a FindControl on it later to determine its new value when it is selected. Based on this new value I will then get data from a database and fill another placeholder on the page with a...
0
7969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7886
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5431
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.