Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:31:58+00:00 2026-05-25T22:31:58+00:00

I am having troubles understanding the xhtml syntax for calling a function with an

  • 0

I am having troubles understanding the xhtml syntax for calling a function with an input button. I have searched for this, but cannot find a clear explanation.

This snippet of code is from my book, and it works ok, but I’m not sure exactly how the following line works:

onclick="checkGrade(document.gradeForm.grade.value);" 

From what I can figure out, gradeForm is the form, and then grade is the switch statement? So would you use Foo if you had another switch statement called foo inside the checkGrades function? And I am not sure what document or value are for inside the onClick checkGrade function.

Any help would be very much appreciated!

<script type="text/javascript">

function checkGrade(grade) {
    switch (grade.toUpperCase()) {
    case "A":
    window.alert("Your grade is excellent.")
    break;
case "B":
    window.alert("Your grade is good.")
    break;
case "C":
    window.alert("Your grade is fair.")
    break;
case "D":
    window.alert("You are barely passing.")
    break;
case "F":
    window.alert("You failed.")
    break;
default: 
    window.alert("You did not enter a valid letter grade.");
    break;
    }
}
</script>


<p>Please enter your grade below:</p>
<form action="#" name="gradeForm">
    <input type="text" name="grade" />
    <input type="button" value="Check Grade" onclick="checkGrade(document.gradeForm.grade.value);" />
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:31:58+00:00Added an answer on May 25, 2026 at 10:31 pm

    No, grade refers to the textbox. You’re passing the value of the textbox into the checkGrade function. The switch statement is running over the grade variable, which holds the value of the grade textbox.

    You can’t really “name” a switch statement. The argument to the switch represents the value you are testing.

    document represents your HTML document, and value is the value of the textbox named grade. On another note, it is not recommended to use the onClick attribute in XHTML/HTML. Unobtrusive Javascript is preferred, where you bind a handler to the button. For more details, I recommend reading up on the Document Object Model, specifically The DOM and Javascript.

    How old is this book you’re using?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble understanding why I have to place the button triggering the getJSON
I'm having trouble understanding how to solve this issue, essentially I have two arrays
I am having some troubles understanding the object relationships in Django. I wrote this:
I'm trying to pullout values from a uint8_t array. But I'm having troubles understanding
I'm having trouble understanding this question, and the explanation of the answer for an
I am having a little trouble understanding ServiceKnownType in WCF. Taken from this blog
I'm having trouble understanding coredata with my uitableview. I have rows being deleted and
I'm having some troubles understanding how Guice's singleton instantiations works. I've read the available
I'm having trouble understanding why arrays in C# are covariant and what benefits this
I'm having trouble understanding how QGraphicsItemAnimation's setScaleAt function works. Here's the code I'm using:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.