The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Javascript for more span tags
dinocolato
post Nov 21 2011, 04:40 AM
Post #1


Newbie
*

Group: Members
Posts: 14
Joined: 8-April 10
Member No.: 11,605



hi all,
I have a span tags in a html page near a text field.
If I digit a word in with caps lock enable I show a message near the field.

But my page has 3 fields and 3 span tags. If I digit a word in with caps lock enable a message will be shown near the first field only.

How can I show the message only near the text file that I typing in?

Javascript
if (condition)
document.getElementById('mySpan').style.visibility = 'visible';
else
document.getElementById('mySpan').style.visibility = 'hidden';

HTML
<input type="text" name="myname" onkeypress="capsLock(event)" /><span id="mySpan" style="visibility:hidden;">Warning</span>
<input type="text" name="myname" onkeypress="capsLock(event)" /><span id="mySpan" style="visibility:hidden;">Warning</span>
<input type="text" name="myname" onkeypress="capsLock(event)" /><span id="mySpan" style="visibility:hidden;">Warning</span>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 21 2011, 05:52 AM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 13,723
Joined: 9-August 06
Member No.: 6



You must give the SPANs different ID's and pass that ID to the function I suppose you have.

FYI an ID is supposed to be unique for a page. You can use the same one only once.


--------------------
“Never go to excess, but let moderation be your guide.”
– Cicero

IPB Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 20th May 2013 - 03:28 PM