sohit
sohit

Reputation: 9

How to show checkbox selected in edit page if user select the checkbox on submit

I have a check box simple form with two fileds, on submit I am submitting the values yes or no in the database, now in edit I want to show that checkbox selected.

<div class="form-group col-md-6">
    <label> Is Paid</label></br>
    Yes <input type="checkbox"
               name="paid"
               value="yes"
               value=" <?php echo $row_cat['is_paid']; ?>"  
        />
    No <input type='checkbox' name="paid" value="no"  /> 
</div>

How can I show prefilled checkbox on edit page ?

Upvotes: 0

Views: 1922

Answers (1)

Trishul
Trishul

Reputation: 1028

Try

<div class="form-group col-md-6">
  <label> Is Paid</label></br>
  Yes <input type="checkbox"
             name="paid"
             value="yes"
            <?php echo $row_cat['is_paid']=='yes'?' checked="checked" ':''; ?>  
      />
  No <input type='checkbox'
            name="paid"
            value="no"
           <?php echo $row_cat['is_paid']=='no'?' checked="checked" ':''; ?>  
      /> 
</div>

Upvotes: 1

Related Questions