skipion
10-31-2005, 06:15 PM
I've written this little javascript thingy to let people enter special tags within a textarea, I also implemented a character counter... all works well..though I would like to see the following points added:
- When a 'special tag' button is clicked a 'tag' is placed within the textarea, however the focus aint placed back into the textarea.
- When a text is pasted into the textarea, the character count only works if i scroll up or down, thats not a big issue as long the text is trimmed off when the form is submitted. So how do i trimm off the text on submition ?
- Does this code work on the major browsers ?
- I would like to build in a No javascript message, but havent got a clue on how to do that.
If anyone can help me with one or more of the issues above...thanks !!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
vetchk = 0; cursiefchk=0; maxlimit=125;
function vet() {
if (vetchk==0) {
//document.getElementById("adam").style.fontWeight="bold";
Vetindex.value='*';
adam.value+='[B]';
vetchk=1;
}else{
Vetindex.value='[B]';
adam.value+='';
vetchk=0;}
}
function cursief() {
if (cursiefchk==0) {Cursiefindex.value='*'; adam.value+='[C]'; cursiefchk=1;
}else{
Cursiefindex.value='[C]'; adam.value+=''; cursiefchk=0;}
}
//-->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field, countfield) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
// End -->
</script>
</head>
<body>
<input type="button" name="Vetindex" Value="[B]" style="width: 30px" onClick="vet()">
<input type="button" name="Cursiefindex" Value="[C]" style="width: 30px" onClick="cursief()">
<br>
<textarea id="adam" name="adam" wrap=physical style="width: 600 px; height: 200px;" onKeyDown="textCounter(adam,remLen);" onKeyUp="textCounter(adam,remLen);" onMouseUp="textCounter(adam,remLen);" onmousedown="textCounter(adam,remLen);">
</textarea><br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>
<input type="button" value="Submit">
</body>
</html>
- When a 'special tag' button is clicked a 'tag' is placed within the textarea, however the focus aint placed back into the textarea.
- When a text is pasted into the textarea, the character count only works if i scroll up or down, thats not a big issue as long the text is trimmed off when the form is submitted. So how do i trimm off the text on submition ?
- Does this code work on the major browsers ?
- I would like to build in a No javascript message, but havent got a clue on how to do that.
If anyone can help me with one or more of the issues above...thanks !!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
vetchk = 0; cursiefchk=0; maxlimit=125;
function vet() {
if (vetchk==0) {
//document.getElementById("adam").style.fontWeight="bold";
Vetindex.value='*';
adam.value+='[B]';
vetchk=1;
}else{
Vetindex.value='[B]';
adam.value+='';
vetchk=0;}
}
function cursief() {
if (cursiefchk==0) {Cursiefindex.value='*'; adam.value+='[C]'; cursiefchk=1;
}else{
Cursiefindex.value='[C]'; adam.value+=''; cursiefchk=0;}
}
//-->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field, countfield) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
// End -->
</script>
</head>
<body>
<input type="button" name="Vetindex" Value="[B]" style="width: 30px" onClick="vet()">
<input type="button" name="Cursiefindex" Value="[C]" style="width: 30px" onClick="cursief()">
<br>
<textarea id="adam" name="adam" wrap=physical style="width: 600 px; height: 200px;" onKeyDown="textCounter(adam,remLen);" onKeyUp="textCounter(adam,remLen);" onMouseUp="textCounter(adam,remLen);" onmousedown="textCounter(adam,remLen);">
</textarea><br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>
<input type="button" value="Submit">
</body>
</html>