0

I'm trying to display two values in a textbox but the value should be next line. here is my sample query. here i tried
also its not working. give me a idea to display in a next line.... thank you..

</head>
<?php 
$s='hi';
?>
</br>
<?php
$d='how are you';
?>
<body>
<form id="form1" name="form1" method="post" action="">
  <label>
  <input type="text" name="textfield" value="<?php echo $s."<br />"; echo $d?>" id="textfield" />
  </label>
</form>
2
  • Use textarea instead of input box Commented Feb 8, 2011 at 12:43
  • why do you answer in a comment? answer <> comment... Commented Feb 8, 2011 at 12:45

3 Answers 3

3

Use a textarea, and line breaks instead of <br> elements.

 <textarea name="textfield"><?php echo $s."\n".$d; ?></textarea>

to output the contents of the textarea in a HTML document with proper line breaks, use nl2br().

Sign up to request clarification or add additional context in comments.

Comments

1

You cannot display line breaks in textfields (input type="text"). You will need a <textarea> for that.

Use <textarea><?php echo $s."\n".$d; ?></textarea>

1 Comment

Because textbox is designed to hold single-line text only :) You cann't change/configure it.
1

You should use

<textarea><?php echo $s."\n"; echo $d?></textarea>

instead of

<input type="text"

because textbox supports only single-line text

2 Comments

ok thx distdev... can we use textarea like textbox.. if i want to change the value,backround color etc...
You can do it as for usual textbox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.