echo "<label class=\"control-label col-sm-5\" for=\"badgeid\" style=\"margin-left: -50px;\">Recipient:</label>";
echo "<div class=\"col-sm-4\">";
echo "<p class=\"form-control-static\" style=\"margin-top: -6px;\">";
echo "<input type=\"text\" class=\"form-control\" id=\"reciname\" name=\"reciname\" placeholder=\" Enter Name\" value=\" $reciname\">";
echo "</p>";
echo "</div>";
echo "<div class=\"col-sm-10\"></div>";
In above codes, placeholder is not appearing in the box. May I know how can I fix it?
CodePudding user response:
From what I am getting you are trying to get the <input>
field to have Enter Name
inside.
In HTML, the placeholder is there to provide text when the input
is empty. When you have a value associated with it (in this case $reciname
, which currently has the value test
) the placeholder will not show.
To make the placeholder show you need to assign no value (or just quotes) to the variable $reciname
.
Example:
<?php
//this allows the value to be blank and the placeholder to show.
//if this is assigned a value, then the placeholder will not show, instead it
//will be the value
$reciname="";
echo "<label class=\"control-label col-sm-5\" for=\"badgeid\" style=\"margin-left: -50px;\">Recipient:</label>";
echo "<div class=\"col-sm-4\">";
echo "<p class=\"form-control-static\" style=\"margin-top: -6px;\">";
echo "<input type=\"text\" class=\"form-control\" id=\"reciname\" name=\"reciname\" placeholder=\"Enter Name\" value=\"$reciname\">";
echo "</p>";
echo "</div>";
echo "<div class=\"col-sm-10\"></div>";
?>
Docs:
<input>
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
placeholder
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
value
: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
CodePudding user response:
Your code seems to work. Here is a test: https://www.tehplayground.com/e9h6UnMdcERDjZ3A