Ahmad Farid
Ahmad Farid

Reputation: 14774

How to make a textbox of multiple line type in html?

<input class="FormElement" name="term" id="term"  type="text"> 

What modifications should I do to this textbox to make it multiple line, without the need to modify anything else in the code, like reading its value.

I used to read the input by javascript like that, what should be changed in that as well?

var $term = $("textarea#term").val(); 

Upvotes: 12

Views: 62629

Answers (1)

Nick Craver
Nick Craver

Reputation: 630429

You need a <textarea> with the same name, so replace this:

<input class="FormElement" name="term" id="term" type="text"> 

With this:

<textarea class="FormElement" name="term" id="term" cols="40" rows="4"></textarea>

The rows and cols arguments are the width/height respectively...or use CSS styling to specify the size, like this:

<textarea class="FormElement" name="term" id="term" style="width: 200px; height: 40px;"></textarea>

Upvotes: 28

Related Questions