Try this:
<script>
function doThis(obj)
{
alert(obj.id);
}
</script>
<apex:form>
<apex:inputField value="{!acc.name}" id="myID" onchange="doThis(this);"/>
</apex:form>
If You need the selected object id - use actionSupport:
<script>
function doThis(param)
{
alert(param);
}
</script>
<apex:inputField value="{!MyObject__c.AnotherObject__c}">
<apex:actionSupport event="onchange"
oncomplete="doThis('{!MyObject__c.AnotherObject__c}');"
reRender="none"/>
</apex:inputField>
And finally if you can not (!) use actionSupport - use actionFunction instead:
<script>
function doThis(param)
{
alert(param);
}
</script>
<apex:actionFunction name="preSend"
oncomplete="doThis('{!MyObject__c.AnotherObject__c}');"
reRender="none"/>
<apex:inputField value="{!MyObject__c.AnotherObject__c}" onchange="preSend()"/>