Click here to Skip to main content
15,563,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an error binding the textbox to the variable t of js.
I don't know what the problem is, if the link with the button works.

the problem is in line 9 of the code js

html codigo

<!DOCTYPE html>
<html lang="en" dir="ltr">
    <meta charset="utf-8">
    <title>cajero ero</title>
<img src="cajero.gif" alt="">
<input type="text" name=""  id="dinero">
<input type="button" name="cosa" value="extraer" id="cosaa">
<script type="text/javascript" src="cajero.js"></script>


class Billete {// constructor de billeres nombre y cantidad
      this.valor=v; //valor del billete
      this.cantidad=c;//cantidad de billetes

function entregarDinero (){
  var  t=document.getElementById("dinero");
  var dinero= parseInt(t.valor);

  for (var bi of caja ){ // carga cada elemento de la variable caja a bi en cada ciclo
    if (dinero >0){//comprueba que la cantidad pedida sea mayor que 0
      div =Math.floor(dinero /bi.valor); //hace la division y la redondea por debajo
      if (div > bi.cantidad){
        papeles= bi.cantidad;
        papeles= div;
      entregar.push(new  Billete(bi.valor, papeles) );
  if (dinero > 0){
    console.log("no tengo mas dinero ");

var caja=[];// caja de nuestro cajero automatico Array donde entaran los billetes
var entregar=[];

caja.push (new Billete (50,3));
caja.push (new Billete (20,2));
caja.push (new Billete (10,2));

//caja.push le agrega contenido a la variable caja
// new Billete crea el objeto billete con los parametros
var dinero=2100;
var div=0;
var papeles=0;

var b = document.getElementById('cosaa');
b.addEventListener("click", entregarDinero);

What I have tried:

I have moved the scrip tag of the html and so the connection with the button has worked, but the connection with the text box does not work for me
Updated 18-Dec-21 20:53pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900