On either circuits I posted before, use VCC as 5VDC and R1 as 1KOhm. For the first one RB=100KOhm and for the second one RB=39KOhm.
It should be able to give you what you need for the imput of either 12 or 24VDC.
If boucing turns a problem, just split the RB into two resistors(Rb1=Rb2=Rb/2)...