Parallel Resistor Calculator Full Code

 <html lang="en">

 <head>

 <meta charset="utf-8">

 <meta name="viewport" content="width=device-width, initial-scale=1.0">

 <meta http-equiv="X-UA-Compatible" content="ie=edge">

 <title>Parallel Resistor Calculator</title>

 <link rel="stylesheet" href="css/style.css">

 <link rel="stylesheet" href="https://drive.google.com/uc?id=1mCob9oULi-h85Hu4d0dsSL9l6JBEbztl">

 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" 

rel="stylesheet" integrity="sha384-

1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" 

crossorigin="anonymous">

 </head>

 <body>

 <div class="container">

 <div class="description">

 <div class="row">

 <h4>Parallel Resistor Calculator</h4>

 <div class="col-sm-6" >

 

 <div id="allparallel">

 <input class="incoming" type="text" placeholder="Enter resistance">

 

 <select class="allohm">

<option value="1">Ω</option>

 <option value="1000">kΩ</option>

 <option value="1000000">MΩ</option>

 </select>

<br>

 

 <input class="incoming" type="text" placeholder="Enter resistance">

 <select class="allohm">

 <option value="1">Ω</option>

 <option value="1000">kΩ</option>

 <option value="1000000">MΩ</option>

 </select>

 <br>

 </div>

 <button id="addresistor" type="button" class="bg-pruple" onclick="addr()">Add 

Resistor</button><br>

 <button id="cal" type="button" class="bg-red" onclick="multi()">Calculate</button>

 </div>

 <div id="str"></div>

 </div>

 </div>

 </div>

 </div>

 </div>

 </div> 

 </section>

let brnewpar = document.createElement('br');

 let imgnewpar = document.createElement('img');

 

 

 selectnewpar.className = 'allohm';

selectnewpar.style.marginLeft = '4px';

 optionnew0par.text = 'Ω';

 optionnew1par.text = 'kΩ';

 optionnew2par.text = 'MΩ';

 

 inputnewpar.type = 'text';

 inputnewpar.placeholder = 'Enter resistance';

 inputnewpar.className = 'incoming';

 

 imgnewpar.setAttribute("src", "image/r5.png");

 imgnewpar.setAttribute("height", "100");

 imgnewpar.setAttribute("width", "100");

 allparallel.appendChild(inputnewpar);

 allparallel.appendChild(selectnewpar);

 allparallel.appendChild(brnewpar);

 selectnewpar.appendChild(optionnew0par);

 selectnewpar.appendChild(optionnew1par);

 selectnewpar.appendChild(optionnew2par);

 setpar.appendChild(imgnewpar);

inputnewpar.innerHTML = '';

 }

 

 function multi() {

 let result = 0;

 let rparalelno;

 let incoming = document.getElementsByClassName('incoming');

 let allohm = document.getElementsByClassName('allohm');

 

 for (let i=0; i<incoming.length; i++) {

if (allohm[i].options[0].selected) {

 result = result + (1/Number(incoming[i].value));

 } else if (allohm[i].options[1].selected) {

 result = result + (1/Number(incoming[i].value*1000));

 } else if (allohm[i].options[2].selected) {

 result = result + (1/Number(incoming[i].value*1000000));

 } 

 }

 rparalelno = 1/result;

 str.style.display="block";

 

 str.innerHTML = rparalelno + ' Ω';

 }

Window.addEventListener(‘DOMContentLoaded’, function() {

 

 ‘use strict’;

 Let tab = document.querySelectorAll(‘.header-tab’),

 Header = document.querySelector(‘.header’),

 tabContent = document.querySelectorAll(‘.tabcontent’);

 

 function hideTabContent(a) {

 for (let I = a; I < tabContent.length; i++) {

 tabContent[i].classList.remove(‘show’);

 tabContent[i].classList.add(‘hide’);

 }

 }

 

 hideTabContent(1);

function showTabContent(b) {

 if (tabContent[b].classList.contains(‘hide’)) {

 tabContent[b].classList.remove(‘hide’);

 tabContent[b].classList.add(‘show’);

 }

 }

header.addEventListener('click', function(event) {

 let target = event.target;

 if (target && target.classList.contains('header-tab')) {

 for(let i = 0; i < tab.length; i++) {

 if (target == tab[i]) {

 hideTabContent(0);

 showTabContent(i);

 break;

 }

 }

 }

 

 });

 });</script>

<script src="https://drive.google.com/uc?id=1rdHcydzQIR_H6c36e9w2h1rI3Eb1N9WH"></script>

 </body>

</html>


Download Link 

Post a Comment

0 Comments