How can I set up a function so it's called rather than inline
<p>I was given the following code:</p>

<p>accept</p>

<p>Something like this:</p>

<pre><code>$("input[id^='position_']").change(function() {
    //get the value of the input field marked with "position_x"
    var posX = $(this).val();
    var idArr = $(this).attr("id");
    var idTmp = idArr.split("_");
    var id = idTmp[1];
        var divX = $("div[id='"+id+"']").html();    
    make an ajax call passing the two parameters.
    $.ajax({
        type: "POST",
        url : "your_url",
        data: "pos_x="+posX+"&amp;div_x="+divX,
        success: function(response) {
            alert(response);
        }
    });
});
</code></pre>

<p>I like to keep things simple. Is there a way that I can split this code into a function and then have the function be called here: <code>$("input[id^='position_']").change(function() {</code></p>

<p>Also the function seems kind of complex. What I need is for when a user clicks an input field then I will get the value of that field along with the value of another field in the same row and then send to Ajax. </p>

<p>Can anyone see a way I could simplify this?</p>
