Forums de discussion

Keydown event

thumbnail
Andrej Litowka, modifié il y a 11 années.

Keydown event

Junior Member Publications: 79 Date d'inscription: 30/06/10 Publications récentes
Hi All!

I have following code


<aui:form>
<aui:input name="Field 1" id="val1"></aui:input>
<aui:input name="Field 2" id="val2"></aui:input>
<aui:input name="Result" id="val3"></aui:input>
</aui:form>

<aui:script use="aui-base, node">
var v = A.on('keydown', function(event) {
var v1 = A.one('#<portlet:namespace />val1').get('value');
var v2 = A.one('#<portlet:namespace />val2').get('value');

var result = A.one('#<portlet:namespace />val3');
result.set('value', v1 + v2);
}
);
</aui:script>


The Idea is, that sum of values in Field 1 and 2 should be shown in the Result filed. So if I enter e.g. 1 in the Field 1 nothing happens. If I continue enter and put 2 (so now it's 12) ind the Field 1 the value 1 appears in the Result. And so on. If 3 was entered 12 appears in the Result. What I expected is, when I enter 1, it immediately appears in the result. Then when I enter 2 it also immediatelly appears in the Result.

What is wrong with the script?

Thanks and regards,
Andrej