Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: SV: Help with Javascript Variables Concatenation


Message #1 by "Robert Nyman" <robert.nyman@c...> on Tue, 24 Sep 2002 14:59:42 +0200
Thank you.  That solved the problem!

Anne Do


-----Original Message-----
From: Robert Nyman [mailto:robert.nyman@c...] 
Sent: Tuesday, September 24, 2002 9:00 AM
To: JavaScript HowTo
Subject: [javascript_howto] SV: Help with Javascript Variables Concatenation

The syntax you've used thinks that Fname is an array.

The correct syntax to get the first letter is:
var Fname = document.QuickAdd.First_Name.value.substr(0,1);


/Robert


-----Ursprungligt meddelande-----
Från: anne.do@c... [mailto:anne.do@c...] 
Skickat: den 24 september 2002 14:03
Till: JavaScript HowTo
Ämne: [javascript_howto] Help with Javascript Variables Concatenation


I have this javascript used to create a user's email address (First
letter 
of firstname + last name + @zbx.com) on the fly once the have inputted 
their first name and last name.  The name of the form is Quick Add.  THe

script is below but when I execute it I get error: Object does not
support 
this property or method.  The email field eventually populates after 
getting the error but it shows undefined for the value Fname[0].  How do
I 
put the first letter of a variable correctly?  Can you help?

<SCRIPT LANGUAGE="JavaScript">
<!--
function MakeUser()
{
	var Lname = document.QuickAdd.Last_Name.value
	var Fname = document.QuickAdd.First_Name.value


        var NewEmail = Fname[0] + Lname + "@zbx.com";
	document.QuickAdd.Email.value = NewEmail
	}

//-->
</SCRIPT>


---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20



---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

  Return to Index