Create Radio Button Group - PHP

In here you can crate a radio button  group dynamically.

I have used the Array List Object which has the ID and FULL_NAME columan.


<?php

$i=0;

foreach ($this->approverList as $key => $category) {

if($i==0){
echo("<input type='radio'  . name='Group' value='" . $category->ID . "' checked>" . $category->FULL_NAME . " <br>");

}else{

echo("<input type='radio'  name='Group' value='" . $category->ID . "'>" . $category->FULL_NAME . " <br>");

}

$i++;

}

?>

In order to set the Checked value dynamically .Use the following method.


<input disabled type="radio" name="carrytype"  value="EMPLOYEE" <?php echo ([DBValue From Object]=='EMPLOYEE' ? 'checked' : '');?> > Employee
                    

Comments

Popular posts from this blog

ENOENT: no such file or directory, rename : node_modules/async

react-quill Integrate quill-image-resize-module