non sono un expert di javascript e stavo cercando di capire come utilizzare document

Codice PHP:
function vaiGo(){

var 
ids document.getElementById('posted2');
window.document.location.href='fattura.php?id='+ids;

ma ho il seguente risultato:

fattura.php?id=[object HTMLInputElement]

quindi non riesco a passare il valore presente in posted2