Monday, May 21, 2012

Program/Script in JavaScript to count the number of words in a String

JavaScript + HTML is a powerful, useful combination. Here I am writing a program combining both, which helps in counting the number of words in a string given by the user.

I just googled about this program but found the top results to be faulty. If one puts more than one space in between two words, the counter counts the number of words to be 3. This is something one should plug in such programs to make it fault-free. I have my own program which does the same without counting more than one consecutive spaces, which I think I should share in case it may be helpful to anyone, although its easy.

Just a simple if() conditional statement can correct this error. This wont count consecutive spaces.

To directly see the demo of this, visit here.

We will use charAt, for loop, and if statements.

Below is the code of the program to count the number of words in a sentence (string).


<title> Demo

function count()
var m=f.t1.value
var k=0
if(m.charAt(i)==" ")
if(m.charAt(i+1)!=" ")
alert("Number of words in the string are: "+k)




<form name="f">
<textarea name="t1" cols="50" rows="4">Enter the text</textarea>
<input type="button" value="Count" onClick="countWords();">


This code will generate an alert box on the screen telling the number of words in the statement to the user.

The demo of the above code is here:

Comments, or errors are welcome as always! :)

Happy Scripting! ;)

Sunday, May 20, 2012

HTML Basics

First of all, the common thing which everyone may be knowing: HTML stands for HyperText Markup Language.

There are tags, which are used to represent information or data to the viewer in your own formatted way. Most of the tags have to be closed. e.g. in a sentence: "how are you?", if you want to have "how" in italic, are in bold, and you in italic, bold and underline, you have to use this:

<i>how</i> <b>are</b> <i><b><u>you</i></b></u> ?

Output on the Web Browser will be this:

how are you ?

One has to save the created page in .html format, so that web browsers know this is a html page.

The list of basic tags in HTML and what they do is here:

HTML Basic Tags

Sample Output of Sample
<b> abcd</b> abcd
<i> abcd </i> abcd 
<u> abcd</u> abcd
<big> abcd </big> abcd
<small> abcd </small> abcd
2<sup>nd</sup> 2nd
H<sub>2</sub>O H2O
<s> abcd</s> abcd

In listing these tags in the above table, I have used another tag called <table>. It is helpful in organising and presenting data in an arranged format. I will write about table tag in next post.

In case of ANY kind of doubt, or if you want to criticise me, you're welcome ;)

The Story of Web Designing: Why Web Designing?

Today I am in a mood of writing about Web Designing, HTML, JavaScript, and CSS. Whenever I talk about my interest in Web Designing, people ask me "Why Web Designing?"
I say:

"because I love web designing, and Love is Blind you know ;)"

I just guess I have a passion of becoming a Web Designer, and this passion is inspired by the huge number of various websites on Internet which are one of the biggest companies, with huge turnovers, and public interactions. Creating something which the people will love, or which will help people in some way is what I want to do. Right now, I am just looking for opportunities in web designing, and learning about HTML, PHP, JavaScript and CSS as deep as I can. This is kinda "The Pursuit of Web Designing". :D

Web is one of the greatest inventions of mankind! People are connected by Internet, far away relatives and friends stay in touch via Internet chats, or video chats. This is an interesting thing, as Internet was born to inter-connect a few computers in a Network, but today the same Internet is connecting the whole world! There is a huge potential in this invention. Revolutions have started by using social networks on Internet. Moreover, ideas, entertainment, and whatever you can name, it is there on Internet. This range and power is what fascinates me to work in the field of Website Designing and related codings.

From next post, I will write my notes depending on what I have learnt, for use by people, and myself too, in case I forget about the flow of what I have learnt ;)

Long Live The Internet! \m/

Tuesday, May 8, 2012

Win Nokia's Latest Nokia Lumia 800

      You must be knowing about the latest weapon of Nokia to make a comeback in the smartphone market, Nokia Lumia series phones.

          As a part of their promotions, Nokia and Windows Phone are giving away Nokia Lumia 800 phones daily to users, via Windows Phone's Facebook Page. All one has to do is to tell them your favourite apps which you like, and you can win a Nokia Lumia 800.

Good Luck!

Here's the link to Windows Phone India page.


Poor Developer

The Poor Soul :P

Be Happy With What You've Got

Be Happy With What You have! :)

Some Pics Do Speak, Without Even Uttering A Word

No Words For The Kid

Coming Late To The Class and Pushing Your Friend To Get In First

Troll Fun

Jalianwala Bagh Fact

"The Indians were 'packed together so that one bullet would drive through three or four bodies'; the people 'ran madly this way and the other. When fire was directed upon the centre, they ran to the sides. The fire was then directed to the sides. Many threw themselves down on the ground, and the fire was then directed on the ground. This was continued for eight or ten minutes, and it stopped only when the ammunition had reached the point of exhaustion" - Winston Churchill

Jallianwala Bagh Massacre - On April 13, 1919, a multitude of Punjabi's gathered in Amritsar's Jallian wala Bagh as part of the Sikh Festival "Baisakhi fair" and to protest at these extraordinary measures. The throng, penned in a narrow space smaller than Trafalgar Square, had been peacefully listening to the testimony of victims when Dyer appeared at the head of a contingent of British troops. Giving no word of warning, he ordered 50 soldiers to fire into the gathering, and for 10 to 15 minutes 1,650 rounds of ammunition were unloaded into the screaming, terrified crowd, some of whom were trampled by those desperately trying to escape.

"Love Is ..."- Changing Definitions With Age

By 5 Year Old Girl: "Love Is When He Takes My Chocolates 'n Comes Back With It's Wrapper".

By 15 Year Old Girl: "Love Is When We Get Caught For Bunking The Classes 'n He Takes The Blame".

By 18 Year Old Girl: "Love Is When At Farewell He Hugs Me 'n Tells That We Will Stay In Contact".

By 21 Year Old Girl: "Love Is When He Calls Me Every Night 'n Keeps Talking About Useless Things Whole Night Happily".

By 25 Year Old Girl: "Love Is When He Proposes Me With A Ring 'n Makes A Fool Of Him Self 'n Says : "You Know I Love You".

By 35 Year Old Woman: "Love Is When He Cleans The House Seeing Me Tired".

By 50 Year Old Woman: "Love Is When He Is ILL 'n Still Cracks A Joke To Make Me Laugh".

By 60 Year Old Woman: "Love Is When He Is Taking His Last Breath 'n Saying "I'm Glad As I Know What Love Is" ".

No One Is Going To Love You, If You Don't Love Yourself

We live in a world where everything is resplendent and unique. From a petite caterpillar to the breathtaking rainbows we see during monsoon. God has made each one of us with great exertion and love. We all are born with different talents and capabilities which differentiate us from each other and therefore make us one of a kind. There can never be someone who thinks and feels exactly the same way you do. The sparks in your eyes, tears, and the sound of your heartbeat makes you stand out from others. 

Sometimes people feel extremely diffident because they don’t have a talent/ability that others posses. It can be beauty, flourishing business or something else. They create an inferiority complex and start detaching themselves from the rest of the society. They become intrigued with the personalities of others & start imitating them but they don’t realize that by becoming someone they aren’t will only sabotage their own talents and make things much more byzantine. Why do we fail to acknowledge that beauty lies beneath the skin? We may apply loads of makeup & endure big-ticket surgeries to make ourselves look bewitching but it all will be worthless if we don’t have a magnanimous heart big enough to hold no grudges. We can always try to become successful at any point of time in our lives as it is never too late to try. We weren’t born to accept failure and become no-hopers but to triumph over miseries. How can we expect others to love & respect us when we ourselves don’t? We often complaint about lurking for our Mr. /Ms Perfect and intricacies of facing solitude. Why do you want someone else’s love when the person who can love you the most in this world is “YOU”? “YOU” are the only person who will be with you every moment on the path of life. "YOU" are the only person who will be there for you when no one else is. I’m not saying that one should be self-centered and behave like a selfish brat. There is a vast difference between being self-centered and loving and appreciating yourself.

Praise and think positive about yourself every morning and to your surprise you will find yourself doing the same for others. Start your day by saying, “I’m happy, confident and blessed “and enjoy experiencing the spirits of a gleeful life for the rest of your day!!!!

Written By:

The Real 7 Wonders Of The World

Junior high school students in Chicago were studying the Seven Wonders of the World. At the end of the lesson, the students were asked to list what they considered to be the Seven Wonders of the World. Though there was some disagreement, the following received the most votes:

1. Egypt's Great Pyramids
2. The Taj Mahal in India
3. The Grand Canyon in Arizona
4. The Panama Canal
5. The Empire State Building
6. St. Peter's Basilica
7. China's Great Wall

While gathering the votes, the teacher noted that one student, a quiet girl, hadn't turned in her paper yet. So she asked the girl if she was having trouble with her list. The quiet girl replied, "Yes, a little. I couldn't quite make up my mind because there were so many." The teacher said, "Well, tell us what you have, and maybe we can help."

The girl hesitated, then read, "I think the Seven Wonders of the World are:

1. to touch...
2. to taste...
3. to see...
4. to hear... (She hesitated a little, and then added...)
5. to feel...
6. to laugh...
7. and to love.

The room was so quiet; you could have heard a pin drop.

May this story serve as a gentle reminder to all of us that the things we overlook as simple and ordinary are often the most wonderful - and we don't have to travel anywhere special to experience them.

Enjoy your gifts!

- Anonymous

You Are Unique!

        Think what a remarkable, unduplicatable, and miraculous thing it is to be you! Of all the people who have come and gone on the earth, since the beginning of time, not ONE of them is like YOU!

No one who has ever lived or is to come has had your combination of abilities, talents, appearance, friends, acquaintances, burdens, sorrows and opportunities.

No one’s hair grows exactly the way yours does. No one’s finger prints are like yours. No one has the same combination of secret inside jokes and family expressions that you know.

The few people who laugh at all the same things you do, don’t sneeze the way you do. No one prays about exactly the same concerns as you do. No one is loved by the same combination of people that love you – NO ONE!

No one before, no one to come. YOU ARE ABSOLUTELY UNIQUE!

Enjoy that uniqueness. You do not have to pretend in order to seem more like someone else. You weren’t meant to be like someone else. You do not have to lie to conceal the parts of you that are not like what you see in anyone else.

You were meant to be different. Nowhere ever in all of history will the same things be going on in anyone’s mind, soul and spirit as are going on in yours right now.

If you did not exist, there would be a hole in creation, a gap in history, something missing from the plan for human kind.

Treasure your uniqueness. It is a gift given only to you. Enjoy it and share it!

No one can reach out to others in the same way that you can. No one can speak your words. No one can convey your meanings. No one can comfort with your kind of comfort. No one can bring your kind of understanding to another person.

No one can be cheerful and lighthearted and joyous in your way. No one can smile your smile. No one else can bring the whole unique impact of you to another human being.

Share your uniqueness. Let it be free to flow out among your family and friends and people you meet in the rush and clutter of living wherever you are. That gift of yourself was given you to enjoy and share. Give yourself away!

See it! Receive it! Let it tickle you! Let it inform you and nudge you and inspire you!

- An Unknown Author

A Heart Touching Story - Never Judge Anyone

  A doctor entered the hospital in hurry after being called in for an urgent surgery. He answered the call asap, changed his clothes & went directly to the surgery block. He found the boy's father pacing in the hall waiting for the doctor.

  On seeing the doctor, the dad yelled: "Why did U take all this time to come? Don't U know that my son's life is in danger? Don't U have any sense of responsibility?"

 The doctor smiled & said: "I am sorry, I wasn't in the hospital & I came as fast as I could after receiving the call...... And now, I wish you'd calm down so that I can do my work."

  "Calm down?! What if your son was in this room right now, would U calm down? If your own son dies now what will U do??" said the father angrily.

  The doctor smiled again & replied: "I will say what Job said in the Holy Book "From dust we came & to dust we return, blessed be the name of God".

Doctors cannot prolong lives. Go & intercede for your son, we will do our best by God's grace"
  "Giving advises when we're not concerned is so easy" Murmured the father.
  The Doctor went and did the surgery.
 The surgery took some hours after which the doctor went out happy, "Thank goodness!, your son is saved!" And without waiting for the father's reply he carried on his way running.
  "If U have any question, ask the nurse!!"

  "Why is he so arrogant? He couldn't wait some minutes so that I ask about my son's state!", commented the father when seeing the nurse minutes after the doctor left.
  The nurse answered, tears coming down her face: "His son died yesterday in a road accident, he was in the burial when we called him for your son's surgery. And now that he saved your son's life, he left running to finish his son's burial."

Never judge anyone, because U never know how their life is & what they're going through!

Always Do Your Best To Help Others, No Matter What You're Facing.

Don't forget to SHARE this if you liked it.

A Short Inspirational Story: Peace Of Mind

Today I'm sharing one of my favorite short stories. This one was told by my teacher when I was in grade 5. I hope you enjoy reading it.

   Once Buddha was en route to some place with a few of his disciples. On their journey, they happened to pass a lake. Buddha stopped and asked one of his disciples to fetch water for him as he was feeling thirsty.

 The disciple walked up to the lake. When he reached it, he noticed that some people were washing clothes in the water and a bullock cart was crossing through the lake. Hence, the water was muddy and very turbid. The disciple thought, “How can I give this muddy water to my Lord!” So he came back and told Buddha that the water was unfit for him to drink it.

 After about half an hour, Buddha asked the same disciple to go back to the lake and get him some water to drink. The disciple yieldingly went back to the lake. This time to his surprise, he found that the lake had absolutely clear water in it. The mud had settled down and the water above it looked crystal clear. So he collected some water in a pot and brought it to Buddha. 
Buddha looked at the water, and then he looked up at the disciple and said, 
“ See what you did to make the water clean? You let it be and the mud settled down on its own and so you could get some clear water for me. Your mind is also like that. When it is disturbed, just let it be. Refrain yourself from giving any advices or suggestions to it. Give it a little time. It will settle down on its own. You don’t have to put in any effort to calm it down. It will happen. It is effortless.”

 What did Buddha emphasize here? He said, “It is effortless.” Having 'peace of mind' is not an arduous task; it is a facile process. When there is peace inside you, that peace permeates to the outside. It spreads around you and in the environment, such that people around start feeling that peace and grace.

By guest author,
Vaishali Sharma,
who blogs here.

Take Care About The Critical Things First, There Will Be Plenty Of Time For Other Works

A philosophy professor stood before his class with some items on the table in front of him. When the class began, wordlessly he picked up a very large and empty mayonnaise jar and proceeded to fill it with rocks, about 2 inches in diameter.
He then asked the students if the jar was full. They agreed that it was.
So the professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles, of course, rolled into the open areas between the rocks.
He then asked the students again if the jar was full. They agreed it was.
The professor picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else.
He then asked once more if the jar was full. The students responded with a unanimous “Yes.”
“Now,” said the professor, “I want you to recognize that this jar represents your life. The rocks are the important things – your family, your partner, your health, your children – things that if everything else was lost and only they remained, your life would still be full.
The pebbles are the other things that matter – like your job, your house, your car.
The sand is everything else. The small stuff.”
“If you put the sand into the jar first,” he continued “there is no room for the pebbles or the rocks. The same goes for your life.
If you spend all your time and energy on the small stuff, you will never have room for the things that are important to you. Pay attention to the things that are critical to your happiness. Play with your children. Take your partner out dancing. There will always be time to go to work, clean the house, give a dinner party and fix the disposal.
Take care of the rocks first – the things that really matter. Set your priorities. The rest is just sand.”

A Short Inspirational Story: Never Ever Limit Yourself and Your Capabilities

never ever limit yourself inspirational story

This inspiring story is about Bruce Lee, a legendary martial art master.

“Bruce had me up to three miles a day, really at a good pace. We’d run the three miles in twenty-one or twenty-two minutes. Just under eight minutes a mile [Note: when running on his own in 1968, Lee would get his time down to six-and-a half minutes per mile].

So this morning he said to me “We’re going to go five.” I said, “Bruce, I can’t go five. I’m a helluva lot older than you are, and I can’t do five.” He said, “When we get to three, we’ll shift gears and it’s only two more and you’ll do it.”

I said “Okay, hell, I’ll go for it.” So we get to three, we go into the fourth mile and I’m okay for three or four minutes, and then I really begin to give out. I’m tired, my heart’s pounding, I can’t go any more and so I say to him, “Bruce if I run any more,” –and we’re still running-” if I run any more I’m liable to have a heart attack and die.”

He said, “Then die.” It made me so mad that I went the full five miles.

Afterward I went to the shower and then I wanted to talk to him about it. I said, you know, “Why did you say that?”

He said,

“Because you might as well be dead. Seriously, if you always put limits on what you can do, physical or anything else, it’ll spread over into the rest of your life. It’ll spread into your work, into your morality, into your entire being. There are no limits. There are plateaus, but you must not stay there, you must go beyond them. If it kills you, it kills you. A man must constantly exceed his level.”

From The Art of Expressing the Human Body

By Bruce Lee, John Little

Quotes, and Photos of Steve Jobs

Best Facebook Cover Photos

No Next Time, Either Now or Never