How to load php vars into textboxes and checkboxes?
So i have some text vars in php that i want to load on 开发者_StackOverflow社区some html textboxes, and some other booleam php var that i want to represent the checked or not value of some html textboxes, any ideas of how to do this? Thanks!
<input type="text" name="mytextfield" value="<?php echo $mytextvalue; ?>" />
<input type="checkbox" name="mycheckbox" <?php echo ($isChecked?"checked":""); ?> />
Use the in-line abilities of PHP and dump the values where/when you need them.
<input type="text" name="first_name" value="<?php echo $first_name; ?>" />
<input type="checkbox" name="remember_me" value="yes" <?php if ($checked == true) echo 'checked'; ?> />
<?php $default = "foo"; ?>
<input type="text" value="<?php echo $default; ?>" />
<?php $bool = true; ?>
<input type="checkbox" <?php if($bool) echo "CHECKED"; ?> />
精彩评论