Issue with slider in IE (7,8, and 9)

I have been banging my head against the wall with this one. I am working on a survey that uses javascript to rewrite the document repeatedly (I know, but this is how my client wants it done). The slider shows up fine in Firefox, Chrome, Opera, and even on my Android phone, but not in IE. F12 tells me ‘dhtmlxSlider’ is undefined. I found the older thread that suggested putting the code for the slider outside the form, but that didn’t work either. Here is the function that generates the HTML/JS code for the slider. This function is called to place the code inline where the slider needs to go, which is inside a frame and inside a form.

[code]function slide(min,max,start,textID,spanID,units,eventLink,contextSpanID){
escript = “slider.attachEvent(‘onChange’,handler);”
hfunc = “function handler(pos,slider){var x=pos%10;if (Math.floor(x)==0){x=1+x/10};var n=Math.round(x*Math.pow(10,Math.floor(pos/10)));document.getElementById('”+textID+“‘).value=top.addCommas(n);document.getElementById(’”+spanID+“').innerHTML=top.toWords(n,”+money+“)+'”+units+“';”
if (eventLink) {
hfunc = hfunc + “slider2.setMax(pos);slider2.setValue(pos);”
} else if (contextSpanID) {
hfunc = hfunc + “document.getElementById('” + contextSpanID + “').innerHTML=top.monetaryContext(n);”
hfunc = hfunc + “}”

if (min==null || min==“”){min=0}
if (max==null || max==“”){max=min*10}
if (start==null || start==“”){start=min}
return “<scr” + “ipt>window.dhx_globalImgPath = "codebase/imgs/";</scr”+“ipt><scr”+“ipt src="codebase/dhtmlxcommon.js"></scr”+“ipt><scr”+“ipt src="codebase/dhtmlxslider.js"></scr”+“ipt><scr”+“ipt src="codebase/ext/dhtmlxslider_start.js"></scr”+“ipt><scr”+“ipt>var slider = new dhtmlxSlider(null,700,null,null,”+min+“,”+max+“,” + start+“);” + escript + “slider.init();” + hfunc + “</scr” + “ipt>”

Thanks for any help you can give me!

I figured out how to make it work for anyone else interested. Instead of using document.write() to rewrite the entire document, I created a div with id=‘bodytext’ and use document.getElementById(‘bodytext’).innerHTML. I can then initialize the slider with an argument for the parent element and IE now finds it.

To reproduce your issue attach complete demo, please: … leted_demo