gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
برنامه حسابداری ساده فارسی به زبان جاوا اسکریپت برام بساز و طراحی کن
- User
برنامه حسابداری ساده فارسی به زبان جاوا اسکریپت برام بساز و طراحی کن
- Assistant
در اینجا یک برنامه حسابداری ساده به زبان جاوا اسکریپت و HTML برای شما آماده کردهام:
- ابتدا فایل HTML را ایجاد کنید و کد زیر را در آن بگذارید:
<!DOCTYPE html> <html lang="fa"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>برنامه حسابداری ساده</title> <style> body { font-family: "Tahoma", sans-serif; direction: rtl; } .container { margin: 1rem auto; max-width: 600px; } table { width: 100%; border-collapse: collapse; } table th, table td { border: 1px solid #333; padding: 0.5rem; } </style> </head> <body> <div class="container"> <h1>برنامه حسابداری ساده</h1> <form id="accounting-form"> <label for="description"> شرح: </label> <input type="text" id="description" name="description" required> <br> <label for="amount"> مبلغ: </label> <input type="number" id="amount" name="amount" required> <br> <input type="submit" value="افزودن"> </form> <hr> <table id="transactions-table"> <thead> <tr> <th>ردیف</th> <th>شرح</th> <th>مبلغ</th> </tr> </thead> <tbody> </tbody> <tfoot> <tr> <td>جمع کل</td> <td colspan="2" id="total-amount"></td> </tr> </tfoot> </table> </div> <script src="app.js"></script> </body> </html>- اکنون فایل جاوا اسکریپت را با نام app.js ایجاد کنید و کد زیر را در آن بگذارید:
document.addEventListener("DOMContentLoaded", function () { const accountingForm = document.getElementById("accounting-form"); const transactionsTable = document.getElementById("transactions-table"); const totalAmount = document.getElementById("total-amount"); let transactions = []; let sum = 0; accountingForm.addEventListener("submit", function (event) { event.preventDefault(); const description = this.elements["description"].value; const amount = parseInt(this.elements["amount"].value); transactions.push({ description: description, amount: amount }); renderTransactions(); this.reset(); }); function renderTransactions() { const tbody = transactionsTable.tBodies[0]; tbody.innerHTML = ""; transactions.forEach(function (transaction, index) { const row = tbody.insertRow(); {هزینه} const cellIndex = row.insertCell(); cellIndex.textContent = index + 1; const cellDescription = row.insertCell(); cellDescription.textContent = transaction.description; const cellAmount = row.insertCell(); cellAmount.textContent = transaction.amount.toLocaleString("fa-IR"); sum += transaction.amount; }); totalAmount.textContent = sum.toLocaleString("fa-IR"); } });- حالا کافی است برنامه خود را در یک مرورگر باز کنید و تست کنید.
این برنامه شامل یک فرم برای وارد کردن توضیحات و مبلغ معاملات است و لیست معاملات را به همراه جمع کل در قالب یک جدول نمایش میدهد. وقتی فرم طبق دستورالعمل پر شدهها و ارسال میشود، اطلاعات به جدول اضافه میشوند و مجموع بهروز میشود.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.