<input type="button" id="one" value="1" OnClick='addValue("function(){document.getElementById("one")}")'>
I want to pass the id of this input as argument of addValue function. Where is the mistake here ?
First, move the event listener out of the HTML and then you can access the value from the click events target.
document.getElementById('one').addEventListener('click', function(evt) {
var value = evt.target.value;
addValue(value);
});
Edit: or use @tymeJV's solution, though I'd recommend getting away from inline events.
If you really want to use function as argument of another function then have a look at anonymous functions http://en.wikibooks.org/wiki/JavaScript/Anonymous_Functions, SetTimeout is a good example, you pass a function as an argument to it to call after specific time.
But I think you can accomplish this without passing function as argument as mentioned in the answer of @tymeJV.