javascript原型_使用JavaScript的示例报告卡Web应用程序原型

javascript原型

Hi! At times, beginners always find it hard getting the application of the theory they learn In programming or a particular language.

嗨! 有时,初学者总是很​​难在编程或特定语言中应用他们学到的理论。

In this article, we'll see another application of JavaScript. We'll simply use HTML/CSS/JS.

在本文中,我们将看到JavaScript的另一个应用程序。 我们将只使用HTML / CSS / JS。

We'll make use of :

我们将利用:

  • HTML tables

    HTML表格

  • Basic CSS

    基本CSS

  • JavaScript functions and variable

    JavaScript函数和变量

We'll play around the things mentioned above to get what we desire. So having some idea about them will be needed to understand this article.

我们将围绕上述问题进行尝试,以获取我们想要的东西。 因此,需要对它们有一些了解才能理解本文。

Our project here is solving the problem of calculating the marks using a pen, paper, and calculator.

我们这里的项目正在解决使用笔,纸和计算器计算标记的问题。

So we are going to create a table where the cells can collect input with specific data types.

因此,我们将创建一个表格,单元格可以在其中收集具有特定数据类型的输入。

Sample report card web application  using JS (image 1)

The table will then collect input and calculate the total in a particular cell.

然后,该表将收集输入并计算特定单元格中的总数。

NOTE: You can perform any calculation of your choice. I used this easy calculation for simple understanding.

注意:您可以执行选择的任何计算。 我使用这种简单的计算方法来进行简单的理解。

Also, we need to add an event in the cell where we want to get our results or output.

另外,我们需要在要获取结果或输出的单元格中添加一个事件。

So in this project, I used the onkeypress event which executes a function to get the final output.

因此,在此项目中,我使用了onkeypress事件,该事件执行一个函数以获取最终输出。

The input data is stored in a variable and used.

输入数据存储在变量中并使用。

HTML file:

HTML档案:

Open a text editor and type the code below. Save the file with the name academia.html.

打开文本编辑器,然后输入以下代码。 保存文件名为academia.html

NB: You can still use your desired CSS style!

注意:您仍然可以使用所需CSS样式!

<html>
<head>
<style>
body {
background-color: white;
}
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
th,
td {
padding: 5px;
text-align: center;
}
table {
width: 40%;
background-color: #f1f1c1;
}
table {
text-align: center;
}
</style>
<script type="text/javascript" src="academia js.js">
</script>
</head>
<body>
<center>
<a href="https://www.go237.com"><img src="images/logo.png"></a>
</center>
<br/>
<br/>
<br/>
<br/>
<center>
<table>
<caption><b><font size = 1 >Total = (Mark * Coef)</caption></b></font>
<tr>
<th>STUDENT</th>
<th>MARKS</th>
<th>COEF</th>
<th>TOTAL</th>
</tr>
<tr>
<td>
<input type="text" placeholder="Student" id='s' required />
</td>
<td>
<input type="number" placeholder="Score" id='m' required />
</td>
<td>
<input type="number" placeholder="Coef" id='c' required />
</td>
<td>
<input type="key" onkeypress='calculate();' placeholder="Total" id='t' />
</td>
</tr>
<tr>
<td>
<input type="text" placeholder="Student" id='s2' required />
</td>
<td>
<input type="number" placeholder="Score" id='m2' required />
</td>
<td>
<input type="number" placeholder="Coef" id='c2' required />
</td>
<td>
<input type="key" onkeypress='calculate2();' placeholder="Total" id='t2' />
</td>
</tr>
<tr>
<td>
<input type="text" placeholder="Student" id='s3' required />
</td>
<td>
<input type="number" placeholder="Score" id='m3' required />
</td>
<td>
<input type="number" placeholder="Coef" id='c3' required />
</td>
<td>
<input type="key" onkeypress='calculate3();' placeholder="Total" id='t3' />
</td>
</tr>
<tr>
<td>
<input type="text" placeholder="Student" id='s4' required />
</td>
<td>
<input type="number" placeholder="Score" id='m4' required />
</td>
<td>
<input type="number" placeholder="Coef" id='c4' required />
</td>
<td>
<input type="key" onkeypress='calculate4();' placeholder="Total" id='t4' />
</td>
</tr>
<tr>
<td>
<input type="text" placeholder="Student" id='s5' required />
</td>
<td>
<input type="number" placeholder="Score" id='m5' required />
</td>
<td>
<input type="number" placeholder="Coef" id='c5' required />
</td>
<td>
<input type="key" onkeypress='calculate5();' placeholder="Total" id='t5' />
</td>
</tr>
<tr>
<td>
<input type="text" placeholder="Student" id='s6' required />
</td>
<td>
<input type="number" placeholder="Score" id='m6' required />
</td>
<td>
<input type="number" placeholder="Coef" id='c6' required />
</td>
<td>
<input type="key" onkeypress='calculate6();' placeholder="Total" id='t6' />
</td>
</tr>
</table>
<br/>
<br/>
<img id='pic' src="1.gif" width: '30%'>
<br/>
<br/>
<a href='javascript:Print()'> Print! </a>
<br/>
<br/>
<b><font size = 1 >Tip: press enter at the level of total cell (or total input) to get results.</b></font>
<br/><b><font size = 1 >- Few student fields for prove implementation.</b></font>
<br/><b><font size = 1 >- No full page loading or response needed to get results.</b></font>
<br/><b><font size = 1 >NB: Do not refresh page during or after form filling.</b></font>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<div style="background-color:black; color:white; padding:1px;">
UPGRADE COMING SOON!
</div>
</center>
</body>
</html>

In this project, I used my own CSS styles. You can feel free to use any you desire.

在这个项目中,我使用了自己CSS样式。 您可以随意使用任何您想要的东西。

Open the html file and test out your web application.

打开html文件并测试您的Web应用程序。

JavaScript file:

JavaScript文件:

Save the code below as academia.js

将下面的代码另存为academia.js

function Print() {
window.print();
}
function calculate() {
var j = document.getElementById('s').value;
var e = document.getElementById('m').value;
var s = document.getElementById('c').value;
var u = document.getElementById('t').value;
var g = e * s;
document.getElementById('t').value = g;
document.getElementById('s').value = j;
}
function calculate2() {
var j2 = document.getElementById('s2').value;
var e2 = document.getElementById('m2').value;
var s2 = document.getElementById('c2').value;
var u2 = document.getElementById('t2').value;
var g2 = e2 * s2;
document.getElementById('t2').value = g2;
document.getElementById('s2').value = j2;
}
function calculate3() {
var j3 = document.getElementById('s3').value;
var e3 = document.getElementById('m3').value;
var s3 = document.getElementById('c3').value;
var u3 = document.getElementById('t3').value;
var g3 = e3 * s3;
document.getElementById('t3').value = g3;
document.getElementById('s3').value = j3;
}
function calculate4() {
var j4 = document.getElementById('s4').value;
var e4 = document.getElementById('m4').value;
var s4 = document.getElementById('c4').value;
var u4 = document.getElementById('t4').value;
var g4 = e4 * s4;
document.getElementById('t4').value = g4;
document.getElementById('s4').value = j4;
}
function calculate5() {
var j5 = document.getElementById('s5').value;
var e5 = document.getElementById('m5').value;
var s5 = document.getElementById('c5').value;
var u5 = document.getElementById('t5').value;
var g5 = e5 * s5;
document.getElementById('t5').value = g5;
document.getElementById('s5').value = j5;
}
function calculate6() {
var j6 = document.getElementById('s6').value;
var e6 = document.getElementById('m6').value;
var s6 = document.getElementById('c6').value;
var u6 = document.getElementById('t6').value;
var g6 = e6 * s6;
document.getElementById('t6').value = g6;
document.getElementById('s6').value = j6;
}

Sample report card web application  using JS (image 2)

Some points to note:

需要注意的几点:

  • There's a print function added to print out the table when done.

    完成后添加了打印功能以打印出表格。

  • A rotating GIF has been added.

    旋转GIF已添加。

  • If you look at the JavaScript code, you'll notice that each row has it's function. This makes it difficult and stressful to create a table of about 50 to 1000 students.

    如果查看JavaScript代码,则会注意到每一行都有它的功能。 这使得创建约50至1000个学生的表变得困难且压力很大。

  • Also, you realize that you must perform the key press event to get the calculated output for that row.

    此外,您意识到必须执行按键事件才能获得该行的计算输出。

Coding challenge:

编码挑战:

  • To solve this problem, customize your own application to create several tables without writing different functions for each row.

    要解决此问题,请自定义您自己的应用程序以创建多个表,而无需为每一行编写不同的函数。

  • Add a button at the bottom of the table to perform the calculation for the entire table and print them in each cell.

    在表格底部添加一个按钮,以执行整个表格的计算并将其打印在每个单元格中。

Successful attempt will get a little gift from IncludeHelp team. Send your attempt to [email protected]

成功的尝试将从IncludeHelp团队那里得到一些礼物。 将您的尝试发送到[受电子邮件保护]

Thanks for coding with me. Your comments are most welcome.

感谢您与我一起编码。 非常欢迎您发表评论。

翻译自: https://www.includehelp.com/code-snippets/sample-report-card-web-application-prototype-using-javascript.aspx

javascript原型

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542749.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vb.net cad 块表最后的实体_21个绘图命令+7个技巧,3分钟让你成为CAD高手

绘制图纸需要用到CAD&#xff0c;CAD制图在生活中也是广泛运用&#xff0c;那么学习CAD到底难不难呢&#xff1f;在这里要告诉CAD新手们&#xff0c;世上无难事&#xff0c;可以用3分钟让你成为CAD高手。21个绘图命令A&#xff1a;绘圆弧B&#xff1a;定义块C&#xff1a;画圆D…

本地tomcat启动war包_「shell脚本」懒人运维之自动升级tomcat应用(war包)

准备&#xff1a;提前修改war包里的相关配置&#xff0c;并上传到服务器&#xff1b;根据要自动升级的tomcat应用修改或添加脚本相关内容&#xff1b;tomcat启动脚本如是自己写的&#xff0c;要统一格式命名&#xff0c;如&#xff1a;xxx、xxxTomcat 等&#xff1b;拿到生产使…

python将txt转为字符串_python做第一只小爬虫

“受尽苦难而不厌&#xff0c;此乃修罗之路”本文技术含量过低&#xff0c;请谨慎观看之前用R语言的Rcurl包做过爬虫&#xff0c;给自己的第一感觉是比较费劲&#xff0c;看着看着发际线就愈加亮眼&#xff0c;最后果断丢之。不过好的是和python爬取原理基本一致&#xff0c;且…

c#查找列表指定元素的索引_在集合的指定索引处插入元素 在C#中

c#查找列表指定元素的索引Given a Collection<T> of Integer and we have to insert an element at given index. 给定Integer的Collection <T>&#xff0c;我们必须在给定的索引处插入一个元素。 To insert an element in Collection<T>, we use Insert() …

跨域技术(JSONP与CROS)

JSONP 我们发现&#xff0c;Web页面上调用js文件时不受是否跨域的影响&#xff0c;凡是拥有"src"这个属性的标签都拥有跨域的能力&#xff0c;比如<script>、<img>、<iframe>。那就是说如果要跨域访问数据&#xff0c;就服务端只能把数据放在js格式…

python3 array为什么不能放不同类型的数据_小白入门Python数据科学全教程lt;一gt;...

前言本文讲解了从零开始学习Python数据科学的全过程&#xff0c;涵盖各种工具和方法你将会学习到如何使用python做基本的数据分析你还可以了解机器学习算法的原理和使用说明先说一段题外话。我是一名数据科学家&#xff0c;在用SAS做分析超过5年后&#xff0c;我决定走出舒适区…

c winform 上传文件到mysql_C# winform DevExpress上传图片到数据库【转】

实现功能如下图&#xff1a;注明&#xff1a;此文使用的是DevExpress控件&#xff0c;winform 原生控件也是一样使用方法。1.点击选择图片按钮&#xff0c;功能为通过对话框选择要上传的文件&#xff0c;并将该文件在下面的PictureEdit中显示出来。具体代码如下&#xff1a;pri…

V 8 nfs+drbd+heartbeat

V 8 nfsdrbdheartbeatnfsdrbdheartbeat&#xff0c;nfs或分布式存储mfs只要有单点都可用此方案解决在企业实际生产场景中&#xff0c;nfs是中小企业最常用的存储架构解决方案之一&#xff0c;该架构方案部署简单、维护方便&#xff0c;只需通过配inotifyrsync简单而高效的数据同…

nodemailer使用_如何使用Nodemailer使用HTML作为内容发送电子邮件 Node.js

nodemailer使用Prerequisite: 先决条件&#xff1a; How to send emails using Nodemailer | Node.js 如何使用Nodemailer发送电子邮件。 Node.js How to send emails with attachments using Nodemailer | Node.js 如何使用Nodemailer发送带有附件的电子邮件。 Node.js This …

angularjs 元素重复指定次数_[LeetCode] 442. 数组中重复的数据

[LeetCode] 442. 数组中重复的数据题目链接&#xff1a; https://leetcode-cn.com/problems/find-all-duplicates-in-an-array难度&#xff1a;中等通过率&#xff1a;61.5%题目描述:给定一个整数数组 a&#xff0c;其中1 ≤ a[i] ≤ n &#xff08; n 为数组长度&#xff09;,…

docker 安装mysql 实战文档_docker 安装mysql

PassJava (佳必过) 项目全套学习教程连载中&#xff0c;关注公众号第一时间获取。docker 安装mysql1.下载镜像sudo docker pull mysql:5.7ubuntuVM-0-13-ubuntu:~$ sudo docker pull mysql:5.75.7: Pulling from library/mysqlc499e6d256d6: Pull complete22c4cdf4ea75: Pull c…

python 补前导零_Python正则表达式| 程序从IP地址中删除前导零

python 补前导零Given an IP address as input, write a Python program to remove leading zeros from it. 给定一个IP地址作为输入&#xff0c;编写一个Python程序以从中删除前导零。 Examples: 例子&#xff1a; Input: 216.08.094.196Output: 216.8.94.196Input: 216.08…

眼球追踪

眼球追踪类似于头部追踪&#xff0c;但是图像的呈现取决于使用者眼睛所看的方向。例如&#xff0c;人们可以用“眼神”完成一种镭射枪的瞄准。眼球追踪技术很受VR专家们密切关注。Oculus创始人帕尔默拉奇就曾称其为“VR的心脏”。对于人眼位置的检测&#xff0c;能够为当前所处…

mysql 创建分区表_Mysql分区表及自动创建分区Partition

Range分区表建表语句如下&#xff0c;其中分区键必须和id构成主键和唯一键CREATE TABLE test1 (id char(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT ‘自增主键(guid)‘,create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘创建时间‘,partition_key …

python下载文件暂停恢复_Python关于Threading暂停恢复解决办法

我们都知道python中可以是threading模块实现多线程, 但是模块并没有提供暂停, 恢复和停止线程的方法, 一旦线程对象调用start方法后, 只能等到对应的方法函数运行完毕. 也就是说一旦start后, 线程就属于失控状态. 不过, 我们可以自己实现这些. 一般的方法就是循环地判断一个标志…

信息系统状态过程图_过程状态图中使用的重要术语| 操作系统

信息系统状态过程图1)上下文切换 (1) Context Switching) Whenever a process is transferred within the system, it moves within different states. These states are known as the process states. When a process goes from one state to another state inside the system…

mysql 吧库下的表名都加_mysql数据库表名大小写问题

mysql数据库表名大小写问题mysql数据库linux版本表名、字段名默认大小写敏感&#xff0c;即区分大小写。查看mysql有关大小写参数&#xff1a;lower_case_file_system是一个只读参数&#xff0c;无法被修改&#xff0c;这个参数是用来告诉你在当前的系统平台(linux\windows等)下…

rgb 灰色_金属+RGB+无线,我要买爆这款海盗船VIRTUOSO鉴赏家游戏耳机

海盗船最近新出的旗舰耳机&#xff0c;VIRTUOSO RGB Wireless SE&#xff0c;中文名叫鉴赏家。耳机一改往日欧美电竞风&#xff0c;改走金属质感高大上简约风&#xff0c;不过讲真&#xff0c;这颜值我吃起来很香。考虑文章过长&#xff0c;我先概括一下入手理由&#xff0c;具…

python 基类 派生类_在Python中具有两个子(派生)类的继承示例

python 基类 派生类In this program, we have a parent class named Details and two child classes named Employee and Doctor, we are inheritance the class Details on the classes Employee and Doctor. And, finally creating two objects of Employee and Doctor class…

连接postgresql

# psycopg2enginecreate_engine(postgresqlpsycopg2://scott:tigerlocalhost/mydatabase)#python 连接postgresql使用psycopg2作为默认的DBAPIThe first time a method like Engine.execute()orEngine.connect()is called, the Engine establishes a real DBAPI connection to …