[Javascript] Textareas
Steve Clay
sclay at ufl.edu
Mon Aug 7 14:40:13 CDT 2006
Monday, August 7, 2006, 3:11:09 PM, Terry Riegel wrote:
> <body onload="theform.mytext.setSelectionRange
> (theform.saveloc.value,theform.saveloc.value);">
> <form method="post" action="thispage.html" name="theform">
> <input type="hidden" name="saveloc" value="7148">
> <textarea name="mytext" cols="60" rows="15"></textarea>
> <input type="submit" name="mybutton" value="Save"
> onclick="theform.saveloc.value=theform.mytext.selectionStart;">
> </form>
1. You should move the submit's onclick event to the form's onsubmit event.
You can't be sure that clicking the submit button will be the only way a
form will be submitted. Removing events from the markup would be nice as
well, but it works for now.
2. You'll need another hidden input:
<input type="hidden" name="saveScrollTop" value="">
...and JS to save:
if(theform.mytext.scrollTop)theform.saveScrollTop.value=theform.mytext.scrollTop;
...and load:
if(theform.saveScrollTop.value)theform.mytext.scrollTop.value=theform.saveScrollTop.value;
3. This should provide bare functionality; it won't catch exceptions if
the browser doesn't like you setting scrollTop or anything like that, but
this might get it working.
--
Steve
http://mrclay.org/
More information about the Javascript
mailing list