Martin Nadoll wrote:
> i have a form
> <form name="ftext" id="ftext">
The required `action' attribute is missing.
> <textarea id="text" name="text"></textarea>
> </form>
> [...]
> My Problem:
> when i go into the textarea of form 2 my form 1 loses focus, so i have to
> tell the function in the parameter"nr", where focus was before, so that this
> function can edit document.forms['ftext'].elements['text'].value at the
> right place between "Hello" and "World".
>
> But how to find this value?
> I need something like
> document.forms['ftext'].elements['text'].selectionStart.value
Remove `.value', and store the reference to the previously focused element
somewhere, e.g.
<script type="text/javascript">
var ref = null;
</script>
<... onfocus="ref = this">
<... onfocus="foo(ref)">
You should avoid naming elements "text", though.
> Also it should work in Gecko and IE
The above (save the `.value') works in Gecko, createRange() (in your Subject
header![1]) works in IE/MSHTML.
HTH
PointedEars
___________
[1] <http://jibbering.com/faq/#posting>
P.S.: The pronoun, I, is always spelled with a capital letter.
P.P.S.: There is de.comp.lang.javascript