Coder Social home page Coder Social logo

ama's People

Contributors

kahlil avatar sindresorhus avatar

Watchers

 avatar  avatar

ama's Issues

onchange dropdown

Hello Kahlil,

I have a drop down and a textarea that should only appear if the value of the drop down is equal to a certain value. In my real application, the drop down will be generated dynamically. I was able to get it working the way I want, almost.

When the correct value is selected, the textarea appears but when I change the value, the textarea stays. How can I fix this?
Here's the codepen
https://codepen.io/isogunro/pen/KeRYww?editors=1011

Thanks for any help you can provide.

Dev setup

Hi Kahlil,
What is your current/preferred setup for front-end development - automation tools, tests & deployment?
Does it make a difference is it's a pet project/internal tool or if it something for a customer?

JavaSCript help

Hi,

Thanks for offering to help.
Could you please tell me why view.displayInventory(); method doesn't show anything?

Here's my code

var ticketSystem = {
    buyers: [],
	  adultTickets: 6,
    adultPrice: 22.50,
    childTickets: 7,
    childPrice: 12.50,
 totalTickets: function(){
     return this.adultTickets + this.childTickets;
 },
totalPrice: function(){
     return this.adultPrice + this.childPrice;
 },
sellTickets: function(name, a, c){
  console.log("name: "+name);
  console.log("a: "+a);
  console.log("c: "+c);
   if ((a>0 && a<=this.adultTickets) && (c>0 && c<=this.childTickets)){
      this.adultTickets = this.adultTickets - a;
      this.childTickets = this.childTickets - c;
      this.buyers.push({
       buyerName: name,
       totAdults: a,
       totChildren: c
      })
   }else{
       console.log("You ordered "+a+" adult tickets and "+c+" child tickets, but there are "+this.adultTickets+" adult tickets and "+this.childTickets+" children tickets left.  Please change your purchase order.");
   }

  console.log("List of buyers: ");
  this.buyers.forEach(function(buyer){
    console.log("Name: ---"+buyer.buyerName);
    console.log("Adult Tickets: "+buyer.totAdults);
    console.log("Child Tickets: "+buyer.totChildren);
    console.log("************************************************");
    console.log("Tickets remaining: "+this.totalTickets());
    console.log("************************************************");
  },this);
},
  reviewTicket: function(name){
    for(var x=0; x<=this.buyers.length; x++){
      if (this.buyers[x].buyerName === name){
        alert(this.buyers[x]);
         return this.buyers[x];        
      }
    }
  }
}

var handlers = {
  sellTickets: function(name, a, c){
    var buyer = document.getElementById("name");
    var adult = document.getElementById("adult");
    var child = document.getElementById("child");
    var transaction = document.getElementById("buyT");
    if (transaction.value === "Buy"){
      alert(buyer.value + "-"+adult.value+"-"+child.value);
      ticketSystem.sellTickets(buyer.value, adult.value, child.value);   
    }
  }  
}

var view = {
  displayInventory: function(){      
         var ulTag = document.querySelector("#allSells");
         console.log(ulTag);
    console.log(ticketSystem.buyers);
         ticketSystem.buyers.forEach(function(buyer){           
           console.log("HELLO "+buyer);
         var buyers = document.createElement("li");
         buyers.innerHTML = buyer.buyerName;
         console.log(buyers);
         ulTag.appendChild(buyers);
      });
  }
}

view.displayInventory();

Here's the code in glitch:
https://glitch.com/edit/#!/ubiquitous-sort

Thanks!

About your hairs

Hej,

I’m curious about how long you have been wearing bald head and what was the reason to decide to let ’em grow again 💇‍♂️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.