Hi all
I am trying write a small tool tip that appears in the Top left corner of all the text boxex indicating the length of the field. (specifically for TextArea tag)
I wrote following script to do that. (simply copy the code to a new HTML file and yopu will see how it works.)
But the Problem starts when I place my InputFields within a table. The left and right cordinates start giving me the cordinates for the able. If any one could tell me how to get the cordinates for any given field (IE only I need this for a Intranet app.) I'd be really greatful
Cheeers
kayzee
<script language="javaScript">
//this function is to display the counter for any given text area
function tooltip(strVal,intMax){
document.getElementById('spnToolTip').style.position = 'absolute';
document.getElementById('spnToolTip').style.left = strVal.offsetLeft + strVal.offsetWidth-10;
document.getElementById('spnToolTip').style.top = strVal.offsetTop - 15;
if (strVal.value.length < intMax)
document.getElementById('spnToolTip').style.backgroundColor = 'yellow';
else
document.getElementById('spnToolTip').style.backgroundColor = 'red';
document.getElementById('spnToolTip').innerHTML.display='';
document.getElementById('spnToolTip').innerHTML = 'len ' +strVal.value.length + '/'+ intMax;
text1.clientLeft
}
</script>
<SPAN ID="spnToolTip"> </SPAN>
<input name=text1 onkeyup="tooltip(text1,10);" >
I am trying write a small tool tip that appears in the Top left corner of all the text boxex indicating the length of the field. (specifically for TextArea tag)
I wrote following script to do that. (simply copy the code to a new HTML file and yopu will see how it works.)
But the Problem starts when I place my InputFields within a table. The left and right cordinates start giving me the cordinates for the able. If any one could tell me how to get the cordinates for any given field (IE only I need this for a Intranet app.) I'd be really greatful
Cheeers
kayzee
<script language="javaScript">
//this function is to display the counter for any given text area
function tooltip(strVal,intMax){
document.getElementById('spnToolTip').style.position = 'absolute';
document.getElementById('spnToolTip').style.left = strVal.offsetLeft + strVal.offsetWidth-10;
document.getElementById('spnToolTip').style.top = strVal.offsetTop - 15;
if (strVal.value.length < intMax)
document.getElementById('spnToolTip').style.backgroundColor = 'yellow';
else
document.getElementById('spnToolTip').style.backgroundColor = 'red';
document.getElementById('spnToolTip').innerHTML.display='';
document.getElementById('spnToolTip').innerHTML = 'len ' +strVal.value.length + '/'+ intMax;
text1.clientLeft
}
</script>
<SPAN ID="spnToolTip"> </SPAN>
<input name=text1 onkeyup="tooltip(text1,10);" >