Alex
Alex

Reputation: 6149

PHP questions about inputs and checkboxes

I have 2 questions:

  1. what is the best way to fill an input in php (for example in asp.net: textbox1.Text = "hello";), I tried <input type="text" name="name" value="<?php echo $name?> "> and then in my php script: $name = $myObj['name'];. Is there any other way?
  2. How can I uncheck a checkbox in php and not by renedering the whole checkbox input?

Thanks a lot

Upvotes: 2

Views: 121

Answers (2)

puneet pandey
puneet pandey

Reputation: 1

if you want to check any checkbox if condition is satisfied the use: `

$i = 1;
<input type="checkbox" name="name-field" value="something" <?php if($i== 1){ echo "checked"; } ?> />
?>

Upvotes: -1

Manwal
Manwal

Reputation: 23816

<input type="text" name="name" value="<?php echo $name?>">

To check the boxes, use:

<input type="checkbox" name="check" value="1" <?php if($condition==true)echo "checked"?>>

Upvotes: 2

Related Questions