Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script that adds HTML bold to form

Status
Not open for further replies.

christianbecker

Programmer
Nov 27, 2001
7
0
0
US
Hello,
this is my first time to make a thread. I read the following thread (thread216-169712) that addressed an inquiry for a script that adds HTML bold formating to an asp form. davidbyng replied:

Check vituz post :
Thread216-144664

I tested the code from that thread on Mac with IE 5 and recieved the following error:

Microsoft JScript runtime error
"null" is not an object

this referred to the following line of code

sel=(IE)?doument.selection;(NC)?document.getSelection():null


The following scripts work fine on PC but not on mac. The first one is the one from Thread216-144664. The second one is from a gentleman is Germany.

<!--
var IE=document.all || document.getElementById
var NC=document.layers

function Inserty(){
var prestart,preend,start,end,sel,range,thetext,dvsn,colname,theform,formname,colselname,colsel,effselname,effsel,effname,eff
formname=&quot;myne&quot;
colselname=&quot;colorName&quot;
effselname=&quot;effectName&quot;
theform=document.forms[formname]
colsel=theform[colselname]
effsel=theform[effselname]
colname=colsel.options[colsel.selectedIndex].value
effname=effsel.options[effsel.selectedIndex].text
eff=effsel.options[effsel.selectedIndex].value

dvsn=[&quot;[&quot;,&quot;]&quot;,&quot;[/&quot;]
prestart=&quot;&quot;
preend=&quot;&quot;

if (colname!='none'){
prestart=dvsn[0]+'color '+colname+dvsn[1]
preend=dvsn[2]+'color'+dvsn[1]
}

start=(effname!='color')?prestart+dvsn[0]+eff+dvsn[1]:prestart
end=(effname!='color')?dvsn[2]+eff+dvsn[1]+preend:preend

sel=(IE)?document.selection:(NC)?document.getSelection():null
range=sel.createRange()
thetext=range.text
if (thetext.length){
range.text=start+thetext+end
}}
//-->
</script>



<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
<!--
function FormatText(Tag) {
tmpStartTag = &quot;<&quot; + Tag + &quot;>&quot;;
tmpEndTag = &quot;</&quot; + Tag + &quot;>&quot;;
GetSelection(tmpStartTag, tmpEndTag, null);
}

function GetSelection(strBefore, strAfter, strContent) {
var Selection = document.selection.createRange();
if (Selection.text != &quot;&quot; && Selection.text != null) {
Selection.text = strBefore + Selection.text + strAfter;
} else {
document.News.Text.value = document.News.Text.value + strBefore + strContent + strAfter;
}
}
//-->


I would appreciate any help to make these code work on MAC or any reference to other codes do do the same function that work on mac.

many thanks.

Christian Becker
cbecker@sarasotamagazine.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top