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.pswp.cn/news/542749.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542749.shtml
英文地址,請注明出處:http://en.pswp.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 …