/    Sign up×
Community /Pin to ProfileBookmark

New To Forums – How Close Am I To Completing This?

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>
[/code]

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>
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@andy21aaNov 25.2008 — Welcome Amphidamas,

try changing the name of your form element.
Copy linkTweet thisAlerts:
@AmphidamasauthorNov 25.2008 — Welcome Amphidamas,

try changing the name of your form element.[/QUOTE]


Hi Andy, ?

Just changed it and... Lol! So close... It always seems to be the smallest of errors that fools me. :rolleyes:

Thanks very much for that.
×

Success!

Help @Amphidamas spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...