Reputation: 11
$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?
Upvotes: 0
Views: 62
Reputation: 11310
You're just placing the value $value
there. It doesn't have any sense to have $value
without opening php tag there.
You need to echo the $value
to have assign on 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
Upvotes: 1
Reputation: 10548
echo $value
inside value=""
$value = 3;
<input type="number" name="rowid" value="<?php echo $value;?>" readOnly><br>
OR
<input type="number" name="rowid" value="<?= $value;?>" readOnly><br>
Upvotes: 1
Reputation: 1583
You need to echo the variable
<input type="number" name="rowid" value="<?php echo $value; ?>" readOnly><br>
Upvotes: 1