Get value from 2 fields onChange?

I’m trying to create a script in which I can set the background color gradient with a colorpicker and are using 2 functions to create this, but… Is it possible to do this within 1 function?

This is what i have so far:

From: <input name="backfrom" id="backfrom" class="color" onchange="bcolorFrom(this.color);" style="width:60px;" value="">
To: <input name="backto" id="backto" class="color" onchange="bcolorTo(this.color);" style="width:60px;" value="">

And the javascript:

function bcolorFrom(c){
	var f = document.getElementById('backto').value;
	jQuery("#mif").contents().find("body").css("background", '-webkit-gradient(linear,left top,left bottom, color-stop(0,#'+c+'), color-stop(1,#'+f+'))');
}
function bcolorTo(c){
	var f = document.getElementById('backfrom').value;
	jQuery("#mif").contents().find("body").css("background", '-webkit-gradient(linear,left top,left bottom, color-stop(0,#'+f+'), color-stop(1,#'+c+'))');
}

Hoping for help and thanks in advance :wink:

Have a look at the following jsFiddle, basically it has a 2 in one event listener that can the difference between backfrom and backto without the need to repeat the event callback.