•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,800 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,900 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 933 | Replies: 5
![]() |
•
•
Join Date: May 2006
Posts: 57
Reputation:
Rep Power: 3
Solved Threads: 0
In the following code i am able to change the case of my entered text with each entry of letters.. can you tell how do i dynamically display its length as well without using ajex..
<html>
<head>
<script type="text/javascript">
function length(x)
{
var y=document.getElementById(x).value
document.getElementById(x).value=y.toUpperCase()
}
</script>
</head>
<body>
Enter password: <input type="text" id="fname" onkeyup="length(this.id)">
<br>
length of the password is :
</body>
</html> Something like this?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>sample page</title>
<script type="text/javascript">
//<![CDATA[
function myLength()
{
var element = document.getElementById('fname');
element.value = element.value.toUpperCase();
document.getElementById('len').innerHTML = element.value.length;
}
//]]>
</script>
</head>
<body>
<form id="frm">
<label>Enter password:</label><input type="text" id="fname" onkeyup="myLength();">
<br />
<div>length of the password is: <span id="len"></span></div>
</form>
</body>
</html> I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: May 2006
Posts: 57
Reputation:
Rep Power: 3
Solved Threads: 0
I was trying to change my font colour dynamically.. got a bit messed up...
What changes should i have done?
and when i search in google how do i search these type of things.. a whole day search only returned me normal js but no graphical things.. please provide some good links if you can!
What changes should i have done?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>sample page</title>
<script type="text/javascript">
//<![CDATA[
function myLength()
{
var str = document.getElementById('streng');
var strColor;
var element = document.getElementById('fname');
leng = element.value.length;
document.getElementById('len').innerHTML = leng;
if(leng<=6)
{
str = "Small Word";
strColor= "red";
}
else
{
str = "Big Word";
strColor= "green";
}
document.getElementById('streng').innerHTML = str;
// str.innerHTML = "<span style='color: " + strColor + ";'>" + str + "</span>";
}
//]]>
</script>
</head>
<body>
<form id="frm">
<label>Enter password:</label><input type="text" id="fname" onkeyup="myLength();">
<br />
<div>length of the password is: <span id="len"></span></div>
<br>
<div>The password is : <span id="streng" style="font-size: 20px;"></span></div>
</form>
</body>
</html> Use the 'style' property of HTML elements.
Also read some good tutorials so that you don't have basic queries. Start here.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>sample page</title>
<script type="text/javascript">
//<![CDATA[
function myLength()
{
var str, strColor;
var display = document.getElementById('streng');
var element = document.getElementById('fname');
var leng = element.value.length;
document.getElementById('len').innerHTML = leng;
if(leng <= 3)
{
str = "Weak";
strColor= "red";
}
else if(leng <= 6)
{
str = "Decent";
strColor = "orange";
}
else
{
str = "Strong";
strColor= "green";
}
display.style.color = strColor;
display.innerHTML = str;
}
//]]>
</script>
</head>
<body>
<form id="frm">
<label>Enter password:</label><input type="password" id="fname" onkeyup="myLength();" /><br /><br />
<div>length of the password is: <span id="len"></span></div><br />
<div>The password is : <span id="streng" style="font-size: 20px;"></span></div>
</form>
</body>
</html>Also read some good tutorials so that you don't have basic queries. Start here.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: May 2006
Posts: 57
Reputation:
Rep Power: 3
Solved Threads: 0
Bro i was able to solve it.. just changed
Can you give some helpfull links related to all graphical things of js...Thanx again
else
{
str = "Big Word";
strColor= "green";
}
// document.getElementById('streng').innerHTML = str;
document.getElementById('streng').innerHTML = "<span style='color: " + strColor + ";'>" + str + "</span>";
}
</script>
</head>
<body>
<form id="frm">
<label>Enter password:</label><input type="text" id="fname" onkeyup="myLength();">
<br />
<div>length of the password is: <span id="len"></span></div>
<br>
<div style="width: 100px;">
<span id="streng" style="font-size: 20px;"></span>
<!-- <div>The password is : <span id="streng" style="font-size: 20px;"></span></div> -->
</form>
</body>
</html>Can you give some helpfull links related to all graphical things of js...Thanx again
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- how to jam the text boxes (VB.NET)
- Mouse Problem - Help needed urgently (Viruses, Spyware and other Nasties)
- Data Flow Diagram (Database Design)
- pls heeeeeeeeelp its urgent. (C)
- Pls help with my HJT log (Viruses, Spyware and other Nasties)
- can somebody pls. help me out with my HJT log.. (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: getElementsByName() generates undefined ouput value in a textbox
- Next Thread: Password Strength



Linear Mode