0

I have an object with 3 properties (amount,date,type) .every time the object is called date updates automatically. Here is the code

var Transaction = function(amount, type) {
    this.amount = amount;
    this.type = type;
    this.date = (function() {
        var d = new Date();
        var minutes = d.getMinutes();
        var month = d.getMonth() +1;
        if (minutes<10) {
            return (d.getDate() + "/" + month + "/" + d.getFullYear() + " " + d.getHours() + ":" + "0" + minutes);
        } else {
            return (d.getDate() + "/" + month + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes);
        }
    })();

How can I set it up so that amount can receive the value of an html input field and type the value from radio buttons? I want to use pure JS

Kaitis
  • 628
  • 9
  • 21
  • What have you tried? FYI, [this question](http://stackoverflow.com/questions/9618504/get-radio-button-value-with-javascript) shows how to get the value of a radio button. You can get the value of an input field with `.value`. – Barmar Oct 31 '13 at 21:29

1 Answers1

0

If an input field is passed it will take it's value otherwise just use the value passed

this.amount = amount.value || amount;
this.type = type.value || type;
Jason Harwig
  • 43,743
  • 5
  • 43
  • 44