[英]Can't I set a variable as a textbox value
$value = 3;
<input type="number" name="rowid" value=$value readOnly><br>
I tried setting a variable as textbox value, however,it won't work. 我尝试将变量设置为文本框值,但是它不起作用。 Is it impossible to set a variable as a textbox value? 是否可以将变量设置为文本框值?
您需要回显变量
<input type="number" name="rowid" value="<?php echo $value; ?>" readOnly><br>
echo $value
inside value=""
在value=""
回显$value
$value = 3;
<input type="number" name="rowid" value="<?php echo $value;?>" readOnly><br>
OR 要么
<input type="number" name="rowid" value="<?= $value;?>" readOnly><br>
You're just placing the value $value
there. 您只是将值$value
放在此处。 It doesn't have any sense to have $value
without opening php tag there. 没有在那里打开php标签就没有$value
意义。
You need to echo the $value
to have assign on rowid
. 您需要回显$value
以在rowid
上进行赋值。
You should do 你应该做
<input type="number" name="rowid" value="<?= $value ?>" readOnly><br>
or 要么
<input type="number" name="rowid" value="<?php echo $value ?>" readOnly><br>
Additional Tip : 附加提示:
You can do the debug yourself by seeing the Page's source (view-source://yourpagename.php)
or by Inspecting the area where you starring in from the Browser 您可以通过查看页面的源代码(view-source://yourpagename.php)
或从浏览器中检查您出演的区域来自己进行调试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.