Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textarea and the tab character 3

Status
Not open for further replies.

webmigit

Programmer
Aug 3, 2001
2,027
US
I posted this in the html forum but the only response I got doesn't help me... its a good idea but I know nothing about how to do it.

I'd like let users put a tab in a textarea... Like this " ". Right now they write it up in notepad and then c&p..

Is there javascript to do this? An html option?

The response said that a possibility was a monitor for onkeypress.. Any ideas?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
This appends four spaces whenever a tab is pressed, but it doesn't allow tabs in the middle of the text:
Code:
<html>
<head>
<script type="text/javascript">
<!--
function doTab(field)
{
  if (event.keyCode == 9)
  {
    field.value += "    ";
    return false;
  }
  return true;  
}
// -->
</script>
</head>
<body>
<form name="a">
<input type="text" name="s" onkeydown="return doTab(this);">
</form>
</body>
</html>

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 

The response said that a possibility was a monitor for onkeypress

The response you got (from me) specifically said the opposite of that - that onkeypress would NOT work, and that you should use onkeydown (as with chessbot's example above).

I just thought I'd let you know that that might be why any solution you may have tried may not be working for you.

Hope this helps,
Dan
 
Ah, sorry for the error.

Thanks though, I'll try these at work tomorrow and let you guys know.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top