<Script Language=JavaScript>
function setSelRange(inputEl, selStart, selEnd) {
if (inputEl.setSelectionRange) {
inputEl.focus();
inputEl.setSelectionRange(selStart, selEnd);
} else if (inputEl.createTextRange) {
var range = inputEl.createTextRange();
range.collapse(true);
range.moveEnd(‘character’, selEnd);
range.moveStart(‘character’, selStart);
range.select();
}
}
</script>
The above script sets the cursor position in the textarea at the begining of text. The textarea is already filled with text and I need to edit it, so I can start editing from the top. The scripts work fine.
<textarea rows=15 cols=100 name=‘POST’ onfocus=‘setSelRange(document.multiupdate.POST, 0, 0)’ />
The problem is that I have multiple textareas with names like POST[$i] in the same form. Multiple textarea being submitted to PHP script as an array. So now when I call the function in different textboxes, it doesn’t work.
<form name=multiupdate method=“POST”>
<textarea rows=15 cols=100 name=‘POST[0]’ onfocus=‘setSelRange(document.multiupdate.POST[0], 0, 0)’ />
<textarea rows=15 cols=100 name=‘POST[1]’ onfocus=‘setSelRange(document.multiupdate.POST[1], 0, 0)’ />
<textarea rows=15 cols=100 name=‘POST[2]’ onfocus=‘setSelRange(document.multiupdate.POST[2], 0, 0)’ />
How to overcome these textarea names with square brackets in it?
I am a complete newbie when it comes to javascript and have taken this function from another site.
Can someone please help?