Hai provato a togliere (non generare) il codice html dalla select fino alla fine ? Per vedere se tutto va bene senza quella porzione.