You can use the {!$Component.whateverName}
within the column markup and when the table is rendered, this reference is relative to the row where the markup occurs.
You can pass this id value as a string as well as the reference to the current input element to the function and then retrieve the DOM element from there and perform the math on the values to find the percentage difference between the two values.
Relevant documentation: Best Practices for Accessing Component IDs
Your page markup will look something like this:
<apex:page id="thePage">
<script type="text/javascript">
function compareValues(element, compareTo) {
// get the references to these two DOM elements and create vars for calculation
var thisElement = element,
compareToElement = document.getElementById(compareTo),
quotedValue = parseFloat(thisElement.text),
currentValue = parseFloat(compareToElement.value),
largerValue = null,
smallerValue = null,
percentDifference = null;
// make sure we've got values to work with
if (thisElement && compareToElement && !isNaN(quotedValue) && !isNaN(currentValue)) {
// find the larger and smaller values
largerValue = Math.max(currentValue, quotedValue);
smallerValue = Math.min(currentValue, quotedValue);
// calculate the percentage difference between these numbers, force the parse as base-10
percentDifference = parseInt((largerValue - smallerValue) / ((largerValue + smallerValue) / 2) * 100, 10);
// alert the user of the difference value
if (percentDifference > 10) {
alert('More than 10% difference: ' + percentDifference);
} else {
alert('Less than 10% difference: ' + percentDifference);
}
} else {
// one of the elements is null
alert('One of the elements to compare is null or isn\'t a number.');
}
}
</script>
<apex:pageBlock>
<apex:pageBlockTable id="thePageBlockTable">
<apex:column headerValue="Current annual Consumption">
<apex:outputText value="{!Rec.AQ}" id="currentConsumption" />
</apex:column>
<apex:column headerValue="Annual consumption quoted for" >
<!-- the Component.currentConsumption reference is relative to _this_ row in the table -->
<apex:inputtext value="{!Rec.AQQ}" required="true"
onblur="compareValues(this, '{!$Component.currentConsumption}')" id="quotedConsumption"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
var price=document.getElementById("").value;