...

View Full Version : Cursor Position



sugan
07-16-2007, 10:29 AM
Hi,
I am using a textarea field in a form and the textarea box should allow only specified no. of strings or characters.
I wrote following javascript code which will not allow the user to enter nore than specified no. of characters. The script function worksfine. But my problem is the cursor gets pointed to the initial position of the textbox when scroll bar appears, This issue is only with the firefox but works fine in IE. please help me.



<script language = javascript>
function mlength(){
var mlen = document.sds.back.value;
var siz = mlen.length;
var le = <?php echo($textarea_size); ?>;
if (siz > le) {
mlen = mlen.substring(0,le);
}
document.sds.back.value = mlen;
siz = (le - mlen.length);
document.sds.sizea.value = siz;
}
</script>

form name is sds and field name is back.

Regards,
Sugan

mcjwb
07-16-2007, 11:22 PM
I think you need to use the "innerText" property, rather than the "value" property in firefox, i.e;

document.sds.back.innerText

sugan
07-17-2007, 05:43 AM
Hi,

Thanks a lot. It worked fine.....

Regards,
Sugan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum