Hello everyone! ? I am a newly registered user so this is my first post here. Glad to be a part of the forums!
I have wrote a program to title case a user entered name. The code for this is:
[code]
<html>
<head>
<title>Name Title Case</title>
<script type = “Text/JavaScript”>
<!– Hides the JavaScript from browsers
var username = prompt(“Please enter your full name in lower case…”,””).split(” “);
for (i = 0; i < username.length; i ++)
username[i] = username[i].substring(0,1).toUpperCase() + username[i].substring(1).toLowerCase();
document.write(username.join(” “));
// Ends the hiding comment –>
</script>
</head>
<body>
</body>
</html>
However, I’m actually trying to incorporate this code into a form but I’m finding it very difficult. I’ve been playing around with it for a few hours now but I’m not getting anywhere. I have posted the code below for you guys (and girls ?) to check out. I don’t want someone to simply write the code for me or else I would not be learning anything. What I would like though is to know if I’m close or not, and also possibly a few tips towards getting it working. :rolleyes:
Regards.
[code]
<html>
<head>
<title></title>
<script type = “Text/JavaScript”>
<!–
function nametitlecase(username)
{
var username1 = (username.split(” “));
for (i = 0; i < username1.length; i ++)
username1[i] = username1[i].substring(0,1).toUpperCase() + username1[i].substring(1).toLowerCase();
var joinname = (username1.join(” “));
return joinname
}
//–>
</script>
</head>
<body>
<p>Please enter your full name in lowercase and click on the “Title Case My Name” button…</p>
<form name=”nametitlecase”>
<input type=”text” name=”username” size=”20″ value=””/>
<br /><br />
<input type=”button” onclick=”result.value=nametitlecase(username.value)” value=”Title Case My Name”/>
<br /><br />
<input type=”text” name=”result” size=”20″ value=””/>
</form>
</body>
</html>