User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2006
Posts: 57
Reputation: kaushik259106 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kaushik259106 kaushik259106 is offline Offline
Junior Poster in Training

Help Pls help me related to jS.. urgent

  #1  
Sep 5th, 2007
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>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,859
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Pls help me related to jS.. urgent

  #2  
Sep 5th, 2007
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.
Reply With Quote  
Join Date: May 2006
Posts: 57
Reputation: kaushik259106 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kaushik259106 kaushik259106 is offline Offline
Junior Poster in Training

Re: Pls help me related to jS.. urgent

  #3  
Sep 5th, 2007
ya.. thanx..lots of thanx.. thats what i want
Reply With Quote  
Join Date: May 2006
Posts: 57
Reputation: kaushik259106 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kaushik259106 kaushik259106 is offline Offline
Junior Poster in Training

Re: Pls help me related to jS.. urgent

  #4  
Sep 5th, 2007
I was trying to change my font colour dynamically.. got a bit messed up...

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>
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!
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,859
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Pls help me related to jS.. urgent

  #5  
Sep 5th, 2007
Use the 'style' property of HTML elements.

<!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.
Reply With Quote  
Join Date: May 2006
Posts: 57
Reputation: kaushik259106 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kaushik259106 kaushik259106 is offline Offline
Junior Poster in Training

Re: Pls help me related to jS.. urgent

  #6  
Sep 5th, 2007
Bro i was able to solve it.. just changed
 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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC