views:

33

answers:

1

Hello

I have a set of input text boxes that activate a calendar for selecting dates when clicked. This works fine.

I now need to get the values entered into these inputs using the onblur event. My problem is that my Javascript isn't detecting the dates entered, but the default value of the input (i.e. garbage). Somehow I need to detect the values the first function is returning, and I have no idea on that at the moment.

Data flow needed:

onclick.input > calendar > input populated > onblur.input > detect new value > ...

When attempting to detect the new value, JS is finding the inital value instead.

The Code: (second set of functions)

var myDates = document.getElementById("step4");
    myDates = myDates.getElementsByTagName("input");

    for (var i = 0; i< myDates.length; i++) {
        myDates[i].onblur = function () { step4param(); return false; };
    }
}

function step4param () {
    var date1 = document.getElementById("day1");
    var date2 = document.getElementById("monthyear1");
    alert (date1.getAttribute("value"));
}

Not sure what parts of the calendar are relevant...

+1  A: 

Ok solved this problem.

Looking at http://stackoverflow.com/questions/146916/javascript-events-getting-notified-of-changes-in-an-input-control-value

I saw a comment that stated getAttribute("value"); will only return the initial value of the input. However someVar.value; will return the current input value. so changing the alert on the last line to

alert (date1.value);

solved the issue.

YsoL8