Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MultiLine Form in HTML?

I'm trying to get some input from a user and use that input in a php script. Right now I have a form tag, from the little I understand, this cannot have multiline input. The solution seems to be a TextArea, however I'm not sure how to get the input from a TextArea.

Here's my code with the form :

<form action="traitement_cmd.php" method="post" >
    Enter Cmd: <input type="text" size="100" maxlength="100" name="cmd"/>
</form>

The textarea tag doesn't seem to have the same attributes as a form tag, so I'm not sure how I should change my code. I also need a button for the user to click to send his input to the php script.

How can I change my code to do this ?

Thank you.

like image 445
JoOb Avatar asked Feb 10 '26 07:02

JoOb


2 Answers

You can just put the textarea inside the form, and the submit button too:

<form action="traitement_cmd.php" method="post" >
	    Enter Cmd: <textarea rows="5" cols="80" name="cmd"></textarea>
		<input type="submit" value="Submit"/>
</form>
like image 94
Rich Avatar answered Feb 13 '26 08:02

Rich


Straight from the source, the HTML 4.01 standard:

This example creates a TEXTAREA control that is 20 rows by 80 columns and contains two lines of text initially. The TEXTAREA is followed by submit and reset buttons.

<FORM action="http://somesite.com/prog/text-read" method="post">
   <P>
   <TEXTAREA name="thetext" rows="20" cols="80">
   First line of initial text.
   Second line of initial text.
   </TEXTAREA>
   <INPUT type="submit" value="Send"><INPUT type="reset">
   </P>
</FORM>
like image 44
Brian Campbell Avatar answered Feb 13 '26 09:02

Brian Campbell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!