![]() |
document.selection.createRange()
Hello,
i have a form <form name="ftext" id="ftext"> <textarea id="text" name="text"></textarea> </form> now i fill in a few words, lets say 'HelloWorld'. Now i put my focus in this form between Hello and World because i want JavaScript to fill something in there by a function called "fillInFormOne()". and than i have another form: <form name="another" id="another" onSubmit="fillInFormOne(nr)"> <textarea id="txt" name="txt"></textarea> </form> Whats going on in real is more complicated, so please dont ask, why i do it like this. I made things simple here. 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 Also it should work in Gecko and IE Thanks for any help on that, Martin Nadoll |
Re: document.selection.createRange()
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 ;-) |
| All times are GMT. The time now is 07:09 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.