473,549 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Script to auto fill fields based on other fields

G'day everyone

I'm not a JavaScript programmer, so I wonder if you could point me in
the right direction or simply tell me how to do the following.

I'd like to submit a patch for the registration page of Pootle
servers. Pootle is a GPL system for translation of software (usually
volunteer work).

What happens is that when a user registers, he fills in his real name,
his preferred user name, and his e-mail address. I would like to add
two more fields, but I want those fields filled in automatically based
on what the user filled in in the previous fields... although if the
user wants to change the information before submitting the form, he
should be able to do so.

At the moment, the fields are:

Username: [_____________]
Real name: [_____________]
E-mail: [______________]

I want to have to more fields:

Display name (public): [_______________ _]
Display name (private): [_______________ _]

If the user's real name is Joe Soap, and his mail address is
jo*@soap.com, I want the public display name to be this:

Joe Soap <joe[at]soap[dot]com>

....and I want the private display name to be this:

Joe Soap <jo*@soap.com >

By filling in this information automatically, I remove the need to
explain to the user what kind of information I want in there. If the
user decides that he does not want to display his name, he can delete
it or further munge it before pressing "Submit".

Ideally, I want the information filled in automatically (either in
real time or when the user's cursor leaves the field) but a solution
that requires the user to press a button or buttons next to the fields
would also be fine.

Is this fairly simple to do? I hope so :-)

Thanks in advance
Samuel (aka leuce, voetleuce)
Sep 16 '08 #1
4 2201
On Sep 16, 10:14*am, Samuel Murray <le...@absamail .co.zawrote:
G'day everyone

I'm not a JavaScript programmer, so I wonder if you could point me in
the right direction or simply tell me how to do the following.

I'd like to submit a patch for the registration page of Pootle
servers. *Pootle is a GPL system for translation of software (usually
volunteer work).

What happens is that when a user registers, he fills in his real name,
his preferred user name, and his e-mail address. *I would like to add
two more fields, but I want those fields filled in automatically based
on what the user filled in in the previous fields... although if the
user wants to change the information before submitting the form, he
should be able to do so.

At the moment, the fields are:

Username: [_____________]
Real name: [_____________]
E-mail: [______________]

I want to have to more fields:

Display name (public): [_______________ _]
Display name (private): [_______________ _]

If the user's real name is Joe Soap, and his mail address is
j...@soap.com, I want the public display name to be this:

Joe Soap <joe[at]soap[dot]com>

...and I want the private display name to be this:

Joe Soap <j...@soap.co m>

By filling in this information automatically, I remove the need to
explain to the user what kind of information I want in there. *If the
user decides that he does not want to display his name, he can delete
it or further munge it before pressing "Submit".

Ideally, I want the information filled in automatically (either in
real time or when the user's cursor leaves the field) but a solution
that requires the user to press a button or buttons next to the fields
would also be fine.

Is this fairly simple to do? *I hope so :-)

Thanks in advance
Samuel (aka leuce, voetleuce)
What you are looking for is RegEx, it makes sense to run a script when
e-mail address (as it is last in your display) looses focus -
concatenate "Real name" and "E-mail" to get the "Display name
(private)" and then use RegEx to replace @ and .(s) with your
replacement strings...
Use Google to find RegEx [Regular Expressions] tutorials
Sep 16 '08 #2
Samuel Murray wrote:
Username: [_____________]
Real name: [_____________]
E-mail: [______________]
I want to have to more fields:
Display name (public): [_______________ _]
Display name (private): [_______________ _]

If the user's real name is Joe Soap, and his mail address is
j...@soap.com, I want the public display name to be this:
Joe Soap <joe[at]soap[dot]com>
...and I want the private display name to be this:
Joe Soap <j...@soap.co m>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Regula r Expression</title>
<script type="text/javascript">
function writenew() {
var f = document.forms[0];
var e = f.email.value.r eplace(/@/, '[at]');
e = e.replace(/\.([a-z]{2,6}$)/i, '[dot]$1');
f.public.value = f.username.valu e + ' <' + e + '>';
f.private.value = f.username.valu e + ' <' + f.email.value + '>';
}
</script>
</head>
<body>
<form method="get" action="#">
<pre>
Username : <input name="username" onKeyUp="writen ew()">
Real name: <input name="realname" onKeyUp="writen ew()">
E-mail : <input name="email" onKeyUp="writen ew()">
Public : <input name="public">
Private : <input name="private">
</pre>
</form>
</body>
</html>

Hope this helps,

--
Bart
Sep 17 '08 #3
On 17 Sep, 17:20, Bart Van der Donck <b...@nijlen.co mwrote:
Samuel Murray wrote:
Username: [_____________]
Real name: [_____________]
E-mail: [______________]
I want to have to more fields:
Display name (public): [_______________ _]
Display name (private): [_______________ _]
If the user's real name is Joe Soap, and his mail address is
j...@soap.com, I want the public display name to be this:
Joe Soap <joe[at]soap[dot]com>
...and I want the private display name to be this:
Joe Soap <j...@soap.co m>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
*"http://www.w3.org/TR/html4/strict.dtd">
<html>
*<head>
* <title>Regula r Expression</title>
* <script type="text/javascript">
* *function writenew() *{
* * var f = document.forms[0];
* * var e = f.email.value.r eplace(/@/, '[at]');
* * e = e.replace(/\.([a-z]{2,6}$)/i, '[dot]$1');
* * f.public.value = f.username.valu e + ' <' + e + '>';
* * f.private.value = f.username.valu e + ' <' + f.email.value + '>';
* *}
* </script>
*</head>
*<body>
* <form method="get" action="#">
* *<pre>
* * Username : <input name="username" onKeyUp="writen ew()">
* * Real name: <input name="realname" onKeyUp="writen ew()">
* * E-mail * : <input name="email" onKeyUp="writen ew()">
* * Public * : <input name="public">
* * Private *: <input name="private">
* *</pre>
* </form>
*</body>
</html>

Hope this helps,

--
*Bart
Hello!

I wan´t a function like this but my first field is the email.

email: ______________

name: _______________
hompage: _______________ _
company: _______________
I want the form to do this:

email: Jo*****@mycompa ny.com

name: Joe Doh <---Autofilled
homepage: http://www.mycompany.com <--- autofilled
company: Mycompany <--- autofilled

All the autofilled parts can you edit after as the orginal script.

Hope you can help me!


Sep 25 '08 #4
On 26 Sep, 00:05, vik...@3on.se wrote:
On 17 Sep, 17:20, Bart Van der Donck <b...@nijlen.co mwrote:


Samuel Murray wrote:
Username: [_____________]
Real name: [_____________]
E-mail: [______________]
I want to have to more fields:
Display name (public): [_______________ _]
Display name (private): [_______________ _]
If the user's real name is Joe Soap, and his mail address is
j...@soap.com, I want the public display name to be this:
Joe Soap <joe[at]soap[dot]com>
...and I want the private display name to be this:
Joe Soap <j...@soap.co m>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
*"http://www.w3.org/TR/html4/strict.dtd">
<html>
*<head>
* <title>Regula r Expression</title>
* <script type="text/javascript">
* *function writenew() *{
* * var f = document.forms[0];
* * var e = f.email.value.r eplace(/@/, '[at]');
* * e = e.replace(/\.([a-z]{2,6}$)/i, '[dot]$1');
* * f.public.value = f.username.valu e + ' <' + e + '>';
* * f.private.value = f.username.valu e + ' <' + f.email.value + '>';
* *}
* </script>
*</head>
*<body>
* <form method="get" action="#">
* *<pre>
* * Username : <input name="username" onKeyUp="writen ew()">
* * Real name: <input name="realname" onKeyUp="writen ew()">
* * E-mail * : <input name="email" onKeyUp="writen ew()">
* * Public * : <input name="public">
* * Private *: <input name="private">
* *</pre>
* </form>
*</body>
</html>
Hope this helps,
--
*Bart

Hello!

I wan´t a function like this but my first field is the email.

email: ______________

name: _______________
hompage: _______________ _
company: _______________

I want the form to do this:

email: Joe....@mycompa ny.com

name: Joe Doh * <---Autofilled
homepage:http://www.mycompany.c om*<--- autofilled
company: Mycompany <--- autofilled

All the autofilled parts can you edit after as the orginal script.

Hope you can help me!- Dölj citerad text -

- Visa citerad text -
Anyone??
Sep 29 '08 #5

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

Similar topics

7
7583
by: Dr. Know | last post by:
I am working on an ASP page that writes to several databases, ranging from MDBs to x-base. One of the tasks involves using an existing highest value from the DB and incrementing it before inserting a new record. I am using Application.Lock and .Unlock together with an application variable to negotiate access to the DB routine to one...
1
6578
by: ogilby1 | last post by:
Using an immediate if to fill a field on a form based on the value of another field. During data entry on the form this methodology works well. When looking at the results in the datasheet view or the underlying table this immediate if field contains the default value that was set when originally setting up the table and the form. ...
4
4703
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)
1
1994
by: Tom G | last post by:
Hello, I need some advice on which way to resolve the following. On a form, the user will make a selection from a combo box, after the selection several different fields need to be updated on the form, based on the selection in the combo box. I have been doing this quite successfully by having the combo box rowsource query contain all...
2
2750
by: Elainie | last post by:
I have been trying to auto fill fields with DLookup - but it doesn't seem to work..... can you help... I have a name field and I want the address to automatically fill in when the name field is filled in. I have load of othre fields that would benefit from this so I need to get it working.... =DLookUp("",""," =") I have an unbound...
0
2686
by: KelHemp | last post by:
Greetings, I've been using this site for lots of access help in the past, and it's very helpful! I have a new complexity for you all. Reworking a form to record 70-80 years of oil production on multiple leases, which have multiple wells within them. Most wells can fit on one printed page (one record), but in the case of overspill, we want...
1
2346
by: Jim | last post by:
I have a new database in which I have a form where in one field I type a letter A, B, C or D and the field next to it autofills (auto lookups) with a description associated with the specific letter. If I edit the description for one record, it edits the same for all records in which I've applied the same autofill (auto lookup). I'm set up...
3
3609
by: jacklindsay | last post by:
Hello smarter people than me I am creating a database for college, and have requested some help, but they are unable to help me. ( im obviously too eager) anyway, im creating a database on computer components and peripherals (i.e networking devices, hard drives etc etc), the previous mentioned devices are in a table called product...
4
3517
by: scolivas | last post by:
I think this is a me thing. but can't remember how to do it. I have a form that I am using and would like for a txt box to automatically populate based on what is selected in a combo box. here is what I have for form fields: Carton # <auto number> Item Title <txt> Item Accquisition Date <txt (date)> Is item consigned <yes/no>
0
7546
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...
0
7740
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7985
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...
0
6071
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5387
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5111
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...
0
3517
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...
1
1962
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
0
784
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...

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.