Gossamer Forum
Home : Products : DBMan : Discussions :

JS problem

Quote Reply
JS problem
If anyone can help me with this...

In a FORM, I want to have two TEXT fields. The first one is a regular input field, i e the user enters his firstname.

The second one automatically updates as the user fills in the first one...

Example: User enter "charles" in the first field. At the same time s/he does this, the second field updates and displays "charles@something.net".

The result: you have two fields dependent on each other, where the second field is the first field+some added text.

This should be a part of a FORM that the user submits.

THANKS!!! :)

Quote Reply
Re: JS problem In reply to
Code:
<HTML>
<HEAD>
<script language="javascript">
<!--
function check() {
myform.email.value = myform.name.value + "@something.com";
}
//-->

</SCRIPT>
</HEAD>
<BODY>
<form name="myform" action="db.cgi" method="POST">
Name:<input type="text" name="name" onkeydown="check();">
Email:<input type="text" name="email" disabled>
</BODY>
</HTML>
That should work :)

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: JS problem In reply to
THANKS!!!!!

Exactly what I was looking for! Perfect!

:)

Quote Reply
Re: JS problem In reply to
Glad to help Smile

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: JS problem In reply to
Hmm you may want to chage:

onkeydown="check();"

to

onblur="check();"

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com