I’ve got a textarea box that contains notes. Above the textarea box there are two buttons Add and Edit. If you click edit it calls a JS function that turns the readOnly property of the textarea to false allowing the user to type something into the box. The Add button does the same thing as the Edit button, but also takes the contents of the textarea and changes it. The first line has a user name, date, and time, the second line is blank, and the previous notes are below the second line. Basically this allows the user to add notes and keeps track of who’s adding them and when. All of this works great in Firefox 2, but not in other browsers. Firefox 1, Opera 8.5, Netscape 8, Mozilla 1.7, and Safari 1 (Mac) all don’t put the new first two lines into the textarea, but they do turn off the readOnly. IE6 and IE7 add the first new line, but it reformats all of the textarea so that there are no hard returns (one continual line of text). IE5 (Mac) the CRLF function doesn’t work. Truefully I don’t care about IE5 (Mac), but thought I’d mention it just in case someone knew something. The codes below, help would greatly be appreciated!!!!!!!!
[CODE]
<script type=”text/javascript”>
function cmdMonth(a){
switch(a){
case 0:
a = “January”
break
case 1:
a = “February”
break
case 2:
a = “March”
break
case 3:
a = “April”
break
case 4:
a = “May”
break
case 5:
a = “June”
break
case 6:
a = “July”
break
case 7:
a = “August”
break
case 8:
a = “September”
break
case 9:
a = “October”
break
case 10:
a = “November”
break
case 11:
a = “December”
break
default:
a = a
}
return a
}
function cmdTime(b,c,d){
var strAMPM = “”;
if(b>11){
d = b – 12;
strAMPM = “pm”;
}
else{
d = b;
strAMPM = “am”;
}
if(c<10){
c = “0” + c
}
d = d + “:” + c + ” ” + strAMPM;
return d;
}
function CRLF(){
return String.fromCharCode(10) + String.fromCharCode(13);
}
function cmdAddNote(){
var strNow = new Date;
var strMonth = cmdMonth(strNow.getMonth());
var strDate = strMonth + ” ” + strNow.getDate() + “, ” + strNow.getFullYear();
var strTime = cmdTime(strNow.getHours(),strNow.getMinutes());
var x = document.forms.UIDInfo.txtNotes;
x.readOnly=false;
x.innerHTML=”*** <% Response.Write Session(“strUser”) %> on ” + strDate + ” at ” + strTime + ” ***” + CRLF() + x.innerHTML;
}
function cmdEditNotes(){
var x = document.forms.UIDInfo.txtNotes;
x.readOnly=false;
}
</script>
TextArea before hitting Add:
[QUOTE]
*** nbcrockett on February 21, 2007 at 9:11 am
Notes from this day
*** nbcrockett on February 21, 2007 at 8:45 am
Notes from this day
TextArea after hitting Add:
[QUOTE]
*** nbcrockett on February 21, 2007 at 11:39 am
*** nbcrockett on February 21, 2007 at 9:11 am
Notes from this day
*** nbcrockett on February 21, 2007 at 8:45 am
Notes from this day