Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,862 members, 7,821,006 topics. Date: Wednesday, 08 May 2024 at 06:40 AM

Help On Javascript! - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help On Javascript! (1663 Views)

Were Can I Download Free Video Tutorials On Javascript Or Ruby / Were Can I Download Free Video Tutorials On Javascript Or Ruby / Need Help On Javascript Issue. (2) (3) (4)

(1) (Reply) (Go Down)

Help On Javascript! by lolade123: 11:23am On Mar 16, 2011
Hi guys pls run this js code and help me fix it.
Thanks in advance. wink

<html>
<head>
<script language ="Javascript">
function checkResult()
{
//Declare Variable
var strGrade;
//Declare the value
strGrade=txtGrade.value;

if (strGrade=="O"wink
{
txtResult.value = "Outstanding";
}
else if(strGrade=="E"wink
{
txtResult.value = "Excellent";
}
else if(strGrade=="VG"wink
{
txtResult.value = "Very Good";
}
else if(strGrade=="G"wink
{
txtResult.value = "Good";
}
else if(strGrade=="A"wink
{
txtResult.value = "Average";
}
else if(strGrade=="F"wink
{
txtResult.value = "Fail";
}
else
{
txtResult.value = "No such grades, ";
}
}//End of checkResult function
</script>
<body>
Enter Your Grade
<input type="text" name="txtGrade"><BR>
RESULT&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<INPUT type="text" name="txtResult" onFocus="checkResult()">
</body>
</html>
Re: Help On Javascript! by naijaswag1: 2:59pm On Mar 16, 2011
<html>
<head>
<script type="text/javascript">
function checkResult()
{
//Declare Variable
var strGrade = document.getElementById("grades"wink.value;

if (strGrade=="O" || strGrade=="o"wink
{
document.getElementById('boton').innerHTML="Outstanding";

}
else if(strGrade=="E" || strGrade== "e"wink
{

document.getElementById('boton').innerHTML="Excellent";

}
else if(strGrade=="VG" || strGrade=="vg"wink
{

document.getElementById('boton').innerHTML="Very Good";
}
else if(strGrade=="G" || strGrade== "g"wink
{

document.getElementById('boton').innerHTML="Good";
}
else if(strGrade=="A" || strGrade== "a"wink
{

document.getElementById('boton').innerHTML="Average";
}
else if(strGrade=="F" || strGrade== "f"wink
{

document.getElementById('boton').innerHTML="Fail";
}
else
{

document.getElementById('boton').innerHTML="No such grades, ";
}
}//End of checkResult function
</script>
<body>
<form>
Enter Your Grade: <input type="text" name="txtGrade" id="grades"><BR />
<p id="boton"><p/>
<input type="button" value="submit" onclick="checkResult()">
</form>
</body>
</html>

Try this.I need some bottles of beer for this.After running it.I will advice that you first of all look at yours and this one and spot the differences(remember that game).I know that you will be surely puzzled but hold your breath,head to http://www.w3schools.com/js/default.asp and see what you can make out for yourself and if you are finding it hard getting along,you can email me (frankgod02@gmail.com or call 08135539123) I live in Lagos,let me teach you, we could do it online and I promise you you wouldn't spend much but will soon be bragging to your friends that you are a javascript guru but mind you this is just the beginning.There are frameworks of js like jquery,dojo and the ajaxxy part of it to ingest.

1 Like

Re: Help On Javascript! by lolade123: 6:04pm On Mar 16, 2011
Thanks i really appreciate you,I would try this out,
Re: Help On Javascript! by lolade123: 8:26pm On Mar 16, 2011
Man your are the best i have ever had. cheesy
i still have more problems on JS,
Am a student of NIIt Ibadan and their JS book has loads of bad codes.
More problems to come ,thanks man.i really appreciate it.
GOD bless you,
GOD bless nairaland,
GOD bless Nigeria. kiss

1 Like

Re: Help On Javascript! by segsalerty(m): 11:23pm On Mar 16, 2011
Smilez grin
Re: Help On Javascript! by naijaswag1: 3:50am On Mar 17, 2011
cheesy I learned the little I know from hopping from one website to another.If you have Java problems,don't hesitate.Dey should contract me to edit that book.The best source of info on any scripting or programming language is the web,that's where I learned from.

Waitn for more.Pay me,you wont but you are ready to pay Indians. grin
Re: Help On Javascript! by segsalerty(m): 6:58am On Mar 17, 2011
how much? and please can u teach me Fahanitelsm and Prerajulization programming in java ? wink
Re: Help On Javascript! by naijaswag1: 11:19am On Mar 17, 2011
@Sagsalerty I know eight people who can teach you those two fanthom programming paradigms plus more,even take you on the nitty gritty of programming a JVM.I will refer you to two of them,if they cannot help you,I will give you another two till the last of them, until you get a solution.They will even teach you future Java9 ahead of 7 and 8 codenamed "quango origo instrujungoaspectaltu".Here comes the two name-Rod Johnson and Gavin King.
Re: Help On Javascript! by lolade123: 2:06pm On Mar 17, 2011
<html>

<head>

<SCRIPT language="JavaScript">

function checkFirstName()

{

//Declamire variables

var firstname;

var firstnamelength;



//assign the values

firstname=txtfirstname.value;

firstnamelength=txtfirstname.value.length;



//Check the length of the first name

if(firstnamelength==0)

{

alert("Please Enter your First Name"wink;

}

}//End of the checkFirstname function

</SCRIPT>

</head>

<body>

Enter your first name

<input type=text name="txtfirstname"><br>

Enter your last name

<input type=text name="txtlastname" onFocus="checkFirstName()">

<input type="submit" name="bd" onClick="checkFirstName()">

</body>

</html>

Ok guys please help me out on this again am loving the experience.God bless you all.
Re: Help On Javascript! by tundebabzy: 9:45pm On Mar 17, 2011
@lolade:
obviously you did not learn anything from from naija swag's earlier solution cos you are making the same mistakes. First, you always have to put the id attribute in your HTML so that you can have access to that element through document.getElementById(). Note that there is also getElementByTag() which will select all tags passed into the function. Google javascript's DOM(document object model).

With this line: <SCRIPT language="JavaScript">, the script can never work. Next time use "javascript" not in camel case like you did hence <SCRIPT language="javascript">

my checkFirstName function would look like this:
function checkFirstName()

{
if (document.getElementById("firstname"wink.value.length == 0)
{
alert("Please Enter Your First Name"wink;
}

}
(no long thing). The function is assuming that the field with name "txtfirstname" has id="firstname".

Dont forget to read(or google javascript DOM) and also learn about XHTML (cos your markup, isnt there yet). I havent tested the javascript but im sure it wont throw an error
Re: Help On Javascript! by tundebabzy: 9:55pm On Mar 17, 2011
Note that the previous code is "a little buggy" because it doesn't address all whitespace so if you click in the first name field and you press the space bar, the alert won't trigger even though the field is empty. To come against this problem, you will have to use regular expressions (google it) to capture all whitespace and integrate that into your code. Hope I haven't confused you
Re: Help On Javascript! by segsalerty(m): 1:19am On Mar 18, 2011
naija_swag:

@Sagsalerty I know eight people who can teach you those two fanthom programming paradigms plus more,even take you on the nitty gritty of programming a JVM.I will refer you to two of them,if they cannot help you,I will give you another two till the last of them, until you get a solution.They will even teach you future Java9 ahead of 7 and 8 codenamed "quango origo instrujungoaspectaltu".Here comes the two name-Rod Johnson and Gavin King.

i thought u are the one to put me thru these stuffs, and i need an online lesson. i asked you how much u wanna collect, not Redirecting me all about !
if u tell me price first, then we go start the chatting ! grin
Re: Help On Javascript! by Afam4eva(m): 12:42pm On Mar 19, 2011
segsalerty:

how much? and please can u teach me Fahanitelsm and Prerajulization programming in java ? wink


haha, have you watched that Indian movie?
Re: Help On Javascript! by naijaswag1: 4:00pm On Mar 19, 2011
segsalerty:

i thought u are the one to put me thru these stuffs, and i need an online lesson. i asked you how much u wanna collect, not Redirecting me all about !
if u tell me price first, then we go start the chatting ! grin

If you are a newbie and you want to learn java,I will be talking to you.What you want to learn can only be taught by these eight people.Consult them and you will be fine.

Instead of providing solutions to the Niit guy,you are here talkng nonsence.You think I dont know you.The customs e-manifest guy.

@afam4eva You have done the right thing by trying to put out niit guy on the right track.

@lolade123 If you read afams post above,you will agree with me that you should taught with a cane because you are not serious.You should have asked questions on how come about the solutions above and then you begin to try before someone stepps in again to help.What I found out is that you dont even understand what js is all about.That is why I refered you to that primary website where you will grab the concept before trying to give yourself heart attack with js.When you show some seriousness,then I can continue.If you visit several tutorials sites hosted by on the web,you have to ask questions not posting codes from a textbook to be corrected by some guy.
Re: Help On Javascript! by segsalerty(m): 10:03pm On Mar 19, 2011
afam4eva:


haha, have you watched that Indian movie?

Uhmm , yes ooo coz my name is Ranchodaz Shamlandas Chanchad alias Segsalerty grin, need to learn some new stunts from DON naija_swag wink , but, now , he is pushing me away

naija_swag:

If you are a newbie and you want to learn java,I will be talking to you.What you want to learn can only be taught by these eight people.Consult them and you will be fine.

Instead of providing solutions to the Niit guy,you are here talkng nonsence.You think I dont know you.The customs e-manifest guy.


Sir, yes, i am a newbie dreaming to learn the greatest of the greatest of coding, I dont need these 8-guyz but You, u still dnt wanna bill me ? kuku teach me for free then, how do u want me to provide solution for the NIIT guy when i need to learn also , ageb ooo, u dnt know me ooo ! am new here,
Re: Help On Javascript! by amdatam: 1:01am On Mar 15, 2013
@lolade123

Using the Switch statement (i.e. less statement writing)

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function checkResult(){

//Declare Variable
var strGrade = document.getElementById("grades" ).value;
switch (strGrade){
case "O":
case "o":

document.getElementById('boton').innerHTML="Outstanding";
break;

case "E":
case "e":

document.getElementById('boton').innerHTML="Excellent";
break;

case "Vg":
case "vg":

document.getElementById('boton').innerHTML="Very Good";
break;

case "G":
case "g":

document.getElementById('boton').innerHTML="Good";
break;

case "A":
case "a":

document.getElementById('boton').innerHTML="Average";
break;

case "F":
case "f":

document.getElementById('boton').innerHTML="Fail";
break;

default:

document.getElementById('boton').innerHTML="Bummer No Grade";
}
}//End of checkResult function
</script>
<body>
<form>
Enter Your Grade: <input type="text" name="txtGrade" id="grades"><br />
<p id="boton"><p/>
<input type="button" value="submit" onClick="checkResult()">
</form>
</body>
</html>

(1) (Reply)

Research Project Topics/thesis For Computer Science Undergraduate / JS Script Not Working(for_in Loop) / Access To My LAN Office Network From Any Location

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 45
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.