Code: Select all
function update_preview(nid, text)
{
if (document.getElementById)
{
x = document.getElementById(nid);
x.innerHTML = text;
}
else if (document.all)
{
x = document.all[nid];
x.innerHTML = text;
}
else if (document.layers)
{
x = document.layers[nid];
x.document.open();
x.document.write(text);
x.document.close();
}
}
function generate_text(field){
var field = field;
var str = document.forms.message.message_box.value; // Yes i know that i have this set werid i couldn't get it to go to the field, but i only need one for now so i just manually set it
// tabs
str = str.replace(/\[tab\]/gi, " ");
// address
str = str.replace(/\[address\]/gi, " <a href=\"directions.htm\">");
str = str.replace(/\[\/address\]/gi, "</a>");
// contact
str = str.replace(/\[contact\]/gi, " <a href=\"contact.htm\">");
str = str.replace(/\[\/contact\]/gi, "</a>");
// paragraph
str = str.replace(/\[p\]/gi, "<p>");
//str = str.replace("[p]"/gi, "<p>");
return str;
}
//-->
I have that code, and it works fine in Firefox, but why doesn't it work in IE.
I have it do text = generate_text('message_box') and then update_preview('preview',text)
EDIT: I've got it down to the str.replaces i thought it was the updating of the preview area, but I really don't understand what you guys are trying to tell me, is anything really wrong with my code?
ADDED: I just read
http://www.dreamincode.net/code/snippet304.htm now I get it... thanks guys