Hi I have a form ( with 4 fields for numbers) and want a javascript function to divide the field input by 100 when we go to next field first i need to know what event should be used the function should be simple but i don't know how to set the argument like: function devideby100(number){ var obj obj = document.getElementById('myfield') obj.value='number/100' } Code (markup): then my fields will be: <input type="text" value="" OnEvent='divideby100();' Code (markup): But I'm sure it won't work. this is my first function in javascript. Please let me know the correct code Thanks in advance
If I understand your request this is what you need function divideby100(obj) { var input = obj.value; if (input.length > 0 && !isNaN(input)) { obj.value = input/100; } else { obj.value = ''; } } Code (markup): <input type="text" onblur="divideby100(this)" /> Code (markup): This protects you when the user types in something other than a number