• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reset the Textarea cursor position at start when click on it

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I am creating dynamically one textarea as follows

<textarea cols="30" rows="3" name="rem[<%= row%>]">
</textarea>

When this page is loaded and when I click on textarea it goes in the middle of 1st row.
I have to click explicitly at start position to bring the cursor at start position.

I want this cursor by default at 1st position when click on it.
How I can do it.Please help.

Thanks
ssn
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is nothing in JSP to help you with this. Moved to the HTML forum.
 
S Nikam
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using below function to remove the whitespaces.
But it will remove whitespaces only from first remark textarea field.

<textarea id="remarks" cols="30" rows="3" name="rem[<%= row%>]" >
</textarea>

function removeTextAreaWhiteSpace() {
var myTxtArea = document.getElementById('remarks');
myTxtArea.value = myTxtArea.value.replace(/^\s*|\s*$/g,'');
}

Thanks
ssn
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "first"? If you have more than one control with the same id value, your markup is invalid.
 
S Nikam
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes bear,thats right.

I am creating textarea controls dynamically depending on records from DB.

Now I have passed removeTextAreaWhiteSpace(this) on control and its working.

<textarea id="remarks" cols="30" rows="3" name="rem[<%= row%>]" onClick="javascript:removeTextAreaWhiteSpace(this)";>

Its weird,as when I click in the middle(where white spaces end), the cursor will be moved from middle to start position.

Thanks
ssn
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you markup is invalid, there's n telling what will happen. Each id value must be unique.
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic