/    Sign up×
Community /Pin to ProfileBookmark

Convert to Uppercase on Click help

Can someone please modify the code below to convert to uppercase on click?

Thank you!
Leppo


————————————————————————–

<html>
<head>
<title>Element Array</title>
<script language=”Javascript”>

function prompt(msg) {
msg.value = msg.value.toUpperCase()
}

</script>
</head>

<body>
<form>
Enter your first name:<input type=”test” name=”firstName” value=”” onChange=”prompt(this)”><p>
Enter your last name:<input type=”test” name=”lastName” value=””
onChange=”prompt(this)”><p>
Enter your address:<input type=”test” name=”address” value=””
onChange=”prompt(this)”><p>
Enter your city:<input type=”test” name=”city” value=””
onChange=”prompt(this)”><p>

<INPUT TYPE=”button” NAME=”Convert” VALUE=”Convert to Uppercase” onClick=”javascript:test=test.toUpperCase()”>

</form>
</body>

</html>
————————————————————————–

to post a comment
JavaScript

14 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 07.2005 — Change all of these:

type="test"

to this:

type="text"

Then, change this:

onClick="javascript:test=test.toUpperCase()"

to this:

onClick="javascript:

firstName.value = firstName.value.toUpperCase();

lastName.value = lastName.value.toUpperCase();

address.value = address.value.toUpperCase();

city.value = city.value.toUpperCase();

retunr true;"
Copy linkTweet thisAlerts:
@Tweak4Jun 07.2005 — Where did <input type=test> come from?

[CODE]<html>
<head>
<title>Element Array</title>
<script language="Javascript">

function prompt(msg) {
msg.value = msg.value.toUpperCase()
}

function UpperCaseAll(){
frmMain.txtFirstName.value = frmMain.txtFirstName.value.toUpperCase();
frmMain.txtLastName.value = frmMain.txtLastName.value.toUpperCase();
frmMain.txtAddress.value = frmMain.txtAddress.value.toUpperCase();
frmMain.txtCity.value = frmMain.txtCity.value.toUpperCase();
}

</script>
</head>

<body>
<form name="frmMain">
Enter your first name:<input type="text" name="txtFirstName" value=""><br>
Enter your last name:<input type="text" name="txtLastName" value=""><br>
Enter your address:<input type="text" name="txtAddress" value=""><br>
Enter your city:<input type="text" name="txtCity" value=""><br>

<INPUT TYPE="button" NAME="Convert" VALUE="Convert to Uppercase" onClick="javascript:UpperCaseAll()">

</form>
</body>
</html>
[/CODE]


Also, "<p>" is [I]not [/I] a line break. Use "<br>" for that.
Copy linkTweet thisAlerts:
@UltimaterJun 07.2005 — Change all of these:

type="test"

to this:

type="text"

Then, change this:

onClick="javascript:test=test.toUpperCase()"

to this:

onClick="javascript:

firstName.value = firstName.value.toUpperCase();

lastName.value = lastName.value.toUpperCase();

address.value = address.value.toUpperCase();

city.value = city.value.toUpperCase();

retu[color=red]r[/color]n true;"[/QUOTE]


Here's the code with his changes:
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Element Array&lt;/title&gt;
&lt;script language="Javascript"&gt;

function prompt(msg) {
msg.value = msg.value.toUpperCase()
}

&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form&gt;
Enter your first name:&lt;input type="text" name="firstName" value="" onChange="prompt(this)"&gt;&lt;p&gt;
Enter your last name:&lt;input type="text" name="lastName" value=""
onChange="prompt(this)"&gt;&lt;p&gt;
Enter your address:&lt;input type="text" name="address" value=""
onChange="prompt(this)"&gt;&lt;p&gt;
Enter your city:&lt;input type="text" name="city" value=""
onChange="prompt(this)"&gt;&lt;p&gt;

&lt;INPUT TYPE="button" NAME="Convert" VALUE="Convert to Uppercase" onClick="javascript:
firstName.value = firstName.value.toUpperCase();
lastName.value = lastName.value.toUpperCase();
address.value = address.value.toUpperCase();
city.value = city.value.toUpperCase();
return true;"&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@LeppoauthorJun 07.2005 — Thank you, phpnovice, Tweak4 and Ultimater!

Do you mind helping me with a few more simple JS programs? ?
Copy linkTweet thisAlerts:
@UltimaterJun 07.2005 — No, I don't mind, what do you have for us?
Copy linkTweet thisAlerts:
@LeppoauthorJun 07.2005 — OK great, Ultimater!

This one consists of 5 HTML pages with JS using frames. Can you modify the code to count the number of page visits?

Thanks!

[SIZE=1]Sorry for the long length.[/SIZE]
--------------------------------------------------------------------------


"Left7.html"

<html>

<head>

<title>Nav Bar</title>

<script language=javascript type="text/javascript">

<!--Hide script from old browsers

page1Count = 0
page2Count = 0
page3Count = 0

pageArray = new Array

("","frame7a.html","frame7b.html","frame7c.html")

function setContent(thisPage) {
parent.content.document.location.href = pageArray[thisPage]
}

//End hiding script from old browsers-->
</script>

</head>

<body bgcolor=white>

<h1> Navagation Bar</h1>

<h2>

<a href="javascript:setContent(1)">Page 1</a><br>

<a href="javascript:setContent(2)">Page 2</a><br>

<a href="javascript:setContent(3)">Page 3</a></h2>

</body>

</html>
--------------------------------------------------------------------------


"frameset7.html"

<html>

<head>

<title>Frame Navigation</title>

</head>

<frameset cols="30%,70%">

<frame src="left7.html" name="left" scrolling=auto>

<frame src="frame7a.html" name="content" scrolling=auto>

</frameset>

</html>
--------------------------------------------------------------------------


"frame7a.html"

<html>

<head>

<title>Content Frame</title>

<script language=javascript type="text/javascript">

<!-- Hide script from old browsers

parent.left.page1Count + +
//End hiding script from old browsers -->


</script>

</head>

<body bgcolor=white>

<h1>You are now looking at page 1.</h1>

<h2>You have been to this page

<script language=javascript type="text/javascript">

<!-- Hide script from old browsers

document.write(parent.left.page1Count)

// End hiding script from old browsers -->

</script>

times.</h2>

</body>

</html>
--------------------------------------------------------------------------


"frame7b.html"

<html>

<head>

<title>Content Frame</title>

<script language=javascript type="text/javascript">

<!-- Hide script from old browsers

parent.left.page2Count + +
//End hiding script from old browsers -->


</script>

</head>

<body bgcolor=white>

<h1>You are now looking at page 2.</h1>

<h2>You have been to this page

<script language=javascript type="text/javascript">

<!-- Hide script from old browsers

document.write(parent.left.page2Count)

// End hiding script from old browsers -->

</script>

times.</h2>

</body>

</html>
--------------------------------------------------------------------------


"frame7c.html"

<html>

<head>

<title>Content Frame</title>

<script language=javascript type="text/javascript">

<!-- Hide script from old browsers

parent.left.page3Count + +
//End hiding script from old browsers -->


</script>

</head>

<body bgcolor=white>

<h1>You are now looking at page 3.</h1>

<h2>You have been to this page

<script language=javascript type="text/javascript">

<!-- Hide script from old browsers

document.write(parent.left.page3Count)

// End hiding script from old browsers -->

</script>

times.</h2>

</body>

</html>
--------------------------------------------------------------------------

Copy linkTweet thisAlerts:
@UltimaterJun 07.2005 — Do you mean that you want an interactive counter that counts all views and saves the information on the server?

Or do you want to only count the page visits from a single user and store the information in a cookie?
Copy linkTweet thisAlerts:
@LeppoauthorJun 07.2005 — Do you want to only count the page visits from a single user and store the information in a cookie?[/QUOTE]Yes, this is what I'm looking for. I'm getting errors when I run the code provided above. ?
Copy linkTweet thisAlerts:
@phpnoviceJun 07.2005 — I'm getting errors...[/QUOTE]
Specify.
Copy linkTweet thisAlerts:
@LeppoauthorJun 07.2005 — Specify.[/QUOTE]It's not displaying page counts . . .

You have been to this page 0 times.
Copy linkTweet thisAlerts:
@phpnoviceJun 07.2005 — Oh, you're referring to the second bit of code you're working on with Ultimater.

I'll step out then. ?
Copy linkTweet thisAlerts:
@UltimaterJun 07.2005 — Here's the flaw in your code:
<i>
</i>parent.left.page1Count + +
parent.left.page2Count + +
parent.left.page3Count + +

+ + isn't the same as ++

Thus:
<i>
</i>parent.left.page1Count++
parent.left.page2Count++
parent.left.page3Count++
Copy linkTweet thisAlerts:
@LeppoauthorJun 07.2005 — Thanks again, Ultimater! It's running perfectly now. Can you help me out here: http://www.webdeveloper.com/forum/showthread.php?t=68706
Copy linkTweet thisAlerts:
@UltimaterJun 07.2005 — Before I that a look at your link, this is the cookie version of what I gave ya:

[upl-file uuid=5e10b7af-e486-478c-a62c-f159808acbca size=2kB]zipped_frame7.zip[/upl-file]
×

Success!

Help @Leppo 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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