Click here to Skip to main content
15,890,825 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: New to JQuery Pin
Richard MacCutchan20-Feb-15 21:47
mveRichard MacCutchan20-Feb-15 21:47 
GeneralRe: New to JQuery Pin
Amarnath S23-Feb-15 5:29
professionalAmarnath S23-Feb-15 5:29 
QuestionGetting text from UL using jquery Pin
indian14319-Feb-15 8:55
indian14319-Feb-15 8:55 
AnswerRe: Getting text from UL using jquery Pin
Dennis E White20-Feb-15 4:56
professionalDennis E White20-Feb-15 4:56 
QuestionI want to move slider/carousel automatically without clicking first to start Pin
Member 1048773918-Feb-15 9:31
Member 1048773918-Feb-15 9:31 
AnswerRe: I want to move slider/carousel automatically without clicking first to start Pin
ZurdoDev19-Feb-15 4:18
professionalZurdoDev19-Feb-15 4:18 
AnswerRe: I want to move slider/carousel automatically without clicking first to start Pin
Santosh K. Tripathi31-Mar-15 1:59
professionalSantosh K. Tripathi31-Mar-15 1:59 
QuestionHelp with arrays assignmet Pin
WebDesignStudent17-Feb-15 6:51
WebDesignStudent17-Feb-15 6:51 
Here is what I have so far. I cant get it to work.

This application stores the last name, first name, and score for one or more students and it calculates the average score for all of the scores that have been entered.
When the user clicks on the Clear button, this application clears the score data from this application.
When the user clicks on the Sort button, this application sorts the data in alphabetical order by last name.
XML
<!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>Student Scores</title>
<link rel="stylesheet" type="text/css" href="default.css" />
<script type="text/javascript" src="student_scores.js"></script>
</head>

<body>
<div id="content">
    <h1>Student Scores</h1>
    <div class="formLayout">
        <label>Last Name:</label>
        <input type="text" id="last_name" /><br />

        <label>First Name:</label>
        <input type="text" id="first_name" /><br />

        <label>Score:</label>
        <input type="text" id="score" /><br />

        <label>&nbsp;</label>
        <input type="button" id="add_button" value="Add Student Score" /><br />
    </div>
    <h2>Student Scores</h2>
    <p><textarea id="scores" rows="5" cols="60"></textarea></p>
    <div class="formLayout">
        <label>Average score:</label>
        <input type="text" id="average_score"/><br />

        <label>&nbsp;</label>
        <input type="button" id="clear_button" value="Clear Student Scores" /><br />

        <label>&nbsp;</label>
        <input type="button" id="sort_button" value="Sort By Last Name" /><br />
    </div>
</body>
</html>



C#
var scores = [];

var $ = function (id) { return document.getElementById(id) }

var displayScores = function () {
    var scoreNumber = parseInt( $("score").value );
    var scoreString = $("last_name").value + ", " +
                      $("first_name").value + ": " +
                      $("score").value;

        if (scoreSting.length == 0) {

    for (var i = 0; i < displayScores.length; i++) {
        var scores = displayScores[i];
        for (var i in scores) { displayScores += scores[scoreString] + ", ";  }
    $("average_score").value = getAverageScore(scoreNumber);
}
var addScore = function () {
    var scoreNumber = parseInt( $("score").value );
    var scoreString = $("last_name").value + ", " +
                      $("first_name").value + ": " +
                      $("score").value;
    scores.push(scoreNumber);
    scoresString.push(scoreString);
    displayScores();
}
var getAverageScore = function () {
    var scoreNumber = score.length;
    var sum = 0;
    if (scoreNumber > 0) {
        for (var i = 0; i in scoreNumber; i++)
            sum += score[i][2];
    }
    $("average_Score").value = sum / scoreNumber;
}
var sortScores = function () {
    scoresString.sort();
    displayScores();
}
}
window.onload = function() {
    $("add_button").onclick = add_button;
    $("sort_button").onclick = sort_button;
}


modified 17-Feb-15 18:14pm.

GeneralRe: Help with arrays Pin
PIEBALDconsult17-Feb-15 6:59
mvePIEBALDconsult17-Feb-15 6:59 
GeneralRe: Help with arrays Pin
PIEBALDconsult17-Feb-15 7:13
mvePIEBALDconsult17-Feb-15 7:13 
QuestionGetting started with Javascript Pin
Atinesh16-Feb-15 6:37
Atinesh16-Feb-15 6:37 
AnswerRe: Getting started with Javascript Pin
Richard MacCutchan16-Feb-15 7:44
mveRichard MacCutchan16-Feb-15 7:44 
AnswerRe: Getting started with Javascript Pin
Amarnath S23-Feb-15 5:27
professionalAmarnath S23-Feb-15 5:27 
AnswerRe: Getting started with Javascript Pin
Anshul Shukla23-Feb-15 5:29
Anshul Shukla23-Feb-15 5:29 
AnswerRe: Getting started with Javascript Pin
Gerd Wagner24-Feb-15 9:41
professionalGerd Wagner24-Feb-15 9:41 
AnswerRe: Getting started with Javascript Pin
Member 1148300326-Feb-15 7:22
Member 1148300326-Feb-15 7:22 
AnswerRe: Getting started with Javascript Pin
Praveen Raghuvanshi5-Apr-15 6:39
professionalPraveen Raghuvanshi5-Apr-15 6:39 
QuestionWhat is the function of Extracting String Characters in JavaScript Pin
Member 1144603412-Feb-15 6:01
Member 1144603412-Feb-15 6:01 
AnswerRe: What is the function of Extracting String Characters in JavaScript Pin
Richard Deeming12-Feb-15 6:23
mveRichard Deeming12-Feb-15 6:23 
GeneralRe: What is the function of Extracting String Characters in JavaScript Pin
Santosh K. Tripathi31-Mar-15 2:04
professionalSantosh K. Tripathi31-Mar-15 2:04 
QuestionI want to write it in aspx or ascx file Pin
indian14310-Feb-15 12:50
indian14310-Feb-15 12:50 
Generalusing ajax Pin
Member 113542638-Feb-15 18:58
Member 113542638-Feb-15 18:58 
SuggestionRe: using ajax Pin
ZurdoDev9-Feb-15 8:47
professionalZurdoDev9-Feb-15 8:47 
GeneralRe: using ajax Pin
Member 113542639-Feb-15 13:30
Member 113542639-Feb-15 13:30 
QuestionWhat is an AXD file Pin
indian1433-Feb-15 14:58
indian1433-Feb-15 14:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.