<div class="col-sm-10">
    <div class="row ">

        <div class="col-sm-12">
            <div class="col-sm-12 gray">
                <div class="col-sm-4 col-sm-offset-8">
                    <form action="#" method="post">
                        <div class="input-group">
                            <input type="text" class="form-control"  placeholder="Search here..." aria-describedby="basic-addon1">
                            <span class="input-group-addon" id="basic-addon1"><i class="fa fa-search"></i></span>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-sm-12">
            <h3>Update Selected Quiz Grade Information</h3>
            <hr>
        </div>

        <div class="col-sm-12">
            <div class="col-sm-12 gray">
                <div class="col-sm-12" ><br></div>
                <?php
//                echo validation_errors(); //formID2
//                $url = 'super-admin/quiz/' . $quiz_info->url . '/edit-grade';
//                echo form_open($url, 'class="" id="formID2" name="add_grade_form" onsubmit="return check_form();"');
                ?>
                <div class="form-group col-sm-5">
                    <div class="input-group">
                        <input type="number" 
                               data-errormessage-value-missing="Grade Total Number is required!"
                               class="form-control validate[required, custom[integer]] text-input" 
                               name="grade_total_number" id="grade_total_number" 
                               value="<?php echo set_value('grade_total_number'); ?>"
                               placeholder="Please Type Total Number.." aria-describedby="basic-addon1">
                        <span class="input-group-addon" id="basic-addon1" title="Please Type Total Number"><i class="fa fa-qrcode"></i></span>
                    </div>
                </div>

                <div class="form-group col-sm-12" ><br></div>

                <div id="Add_Grade">
                    <?php
//                    $grade_number = 0;
//                    if ($quiz_grades) {
//                        foreach ($quiz_grades as $v_grade) {
                            ?>
                            <div id="Grade<?php //echo $grade_number; ?>">
                                <input type="hidden" name="grade_id[]" value="<?php //echo $v_grade->grade_id; ?>">
                                <div class="form-group col-sm-5">
                                    <div class="input-group">
                                        <input type="text" 
                                               data-errormessage-value-missing="Grade Name is required!"
                                               class="form-control validate[required] text-input" 
                                               name="grade_name[]" id="grade_name"
                                               value="<?php
//                                               if (set_value('grade_name')) {
//                                                   echo set_value('grade_name');
//                                               } else {
//                                                   echo $v_grade->grade_name;
//                                               }
                                               ?>" 
                                               placeholder="Please Type Grade Name.." aria-describedby="basic-addon1">
                                        <span class="input-group-addon" id="basic-addon1" title="Please Type Grade Name" ><i class="fa  fa-adn"></i></span>
                                    </div>
                                </div>

                                <div class="form-group col-sm-5">
                                    <div class="input-group">
                                        <input type="number" 
                                               data-errormessage-value-missing="Grade Number is required!"
                                               class="form-control validate[required, custom[integer]] text-input" 
                                               name="grade_number[]" id="grade_number"
                                               value="<?php
//                                               if (set_value('grade_number')) {
//                                                   echo set_value('grade_number');
//                                               } else {
//                                                   echo $v_grade->grade_number;
//                                               }
                                               ?>"
                                               placeholder="Please Type Grade Number.." aria-describedby="basic-addon1">
                                        <span class="input-group-addon" id="basic-addon1" title="Please Type Grade Number" ><i class="fa  fa-qrcode"></i></span>
                                    </div>
                                </div>
                                <div class="form-group col-sm-2 ">
                                    <a href="javascript:void(0)" onclick="cancelGrade('<?php //echo $grade_number; ?>', '<?php //echo $v_grade->grade_id; ?>', 'Cancel')">
                                        <i class="fa fa-times-circle fa-2x"></i>
                                    </a>
                                </div>
                            </div>
                            <?php
//                            $grade_total_number = $v_grade->grade_total_number;
//                            $grade_number++;
//                        }
//                    } else {
                        ?>
                        <div id="Grade0">
                            <div class="form-group col-sm-5">
                                <div class="input-group">
                                    <input type="text" 
                                           data-errormessage-value-missing="Grade Name is required!"
                                           class="form-control validate[required] text-input" 
                                           name="grade_name[]" id="grade_name"
                                           placeholder="Please Type Grade Name.." aria-describedby="basic-addon1">
                                    <span class="input-group-addon" id="basic-addon1" title="Please Type Grade Name" ><i class="fa  fa-adn"></i></span>
                                </div>
                            </div>

                            <div class="form-group col-sm-5">
                                <div class="input-group">
                                    <input type="number" 
                                           data-errormessage-value-missing="Grade Number is required!"
                                           class="form-control validate[required, custom[integer]] text-input" 
                                           name="grade_number[]" id="grade_number"
                                           placeholder="Please Type Grade Number.." aria-describedby="basic-addon1">
                                    <span class="input-group-addon" id="basic-addon1" title="Please Type Grade Number" ><i class="fa  fa-qrcode"></i></span>
                                </div>
                            </div>
                            <div class="form-group col-sm-2 ">
                                <a href="javascript:void(0)" onclick="calcelGrade('<?php //echo $grade_number; ?>', '', 'Cancel');">
                                    <i class="fa fa-times-circle fa-2x"></i>
                                </a>
                            </div>
                        </div>
                        <?php
//                        $grade_number++;
//                    }
                    ?>

                </div>

                <div class="form-group col-sm-12" ><br></div>

                <div class="form-group col-sm-3 col-sm-offset-9">
                    <a href="javascript:void(0)" onclick="AddMoreGrade();" class="green-btn btn btn-success" >Add More.. </a>
                </div>

                <div class="form-group col-sm-12" ><br></div>

                <div class="form-group col-sm-4 col-sm-offset-4">
                    <input type="submit" class="green-btn btn btn-default" value="Update Grade !"><br/><br/>
                </div>
                <div class="col-sm-4"></div>
                <?php //echo form_close(); ?>
            </div>
        </div>
    </div>
    <br>
    <div class="col-sm-12 gray">
        <div class="col-sm-12 text-left">
            <label><a href="<?php //echo base_url() ?>super_admin">Dashboard </a>->>View Grade</label>
        </div>
    </div>
</div>

<script>

                                document.getElementById('grade_total_number').value = "<?php echo $grade_total_number; ?>";
                                var gradeNumber = "<?php echo $grade_number - 1; ?>";
                                var limit = 10;

                                function AddMoreGrade()
                                {
                                    gradeNumber++;
                                    var xmlhttp = create_xmlhttp();
                                    var serverPage = "<?php echo base_url(); ?>" + "super-admin/add_more_grade/" + gradeNumber;
                                    xmlhttp.open("GET", serverPage);
                                    xmlhttp.onreadystatechange = function()
                                    {
                                        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                                        {
                                            var Add_Grade = _('Add_Grade');
                                            var div1 = document.createElement('div');
                                            div1.setAttribute('id', 'Grade' + gradeNumber);
                                            var data1 = xmlhttp.responseText;
                                            div1.innerHTML = data1;
                                            Add_Grade.appendChild(div1);
                                        }
                                    };
                                    xmlhttp.send(null);
                                }


                                function cancelGrade(id, grade_id, action) {

                                    swal({
                                        title: "",
                                        text: "Are you sure you want to " + action + " this grade?",
                                        type: "warning",
                                        showCancelButton: true,
                                        confirmButtonColor: '#DD6B55',
                                        confirmButtonText: 'Yes',
                                        cancelButtonText: "No",
                                        closeOnConfirm: true,
                                        closeOnCancel: true
                                    },
                                    function(isConfirm) {
                                        if (isConfirm) {
                                            _('Grade' + id).innerHTML = '';
                                            if (grade_id != '') {
                                                var xmlhttp = create_xmlhttp();
                                                var serverPage = '<?php echo base_url() ?>' + 'super-admin/delete_grade/' + grade_id;
                                                xmlhttp.open("GET", serverPage);
                                                xmlhttp.onreadystatechange = function()
                                                {
                                                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                                                    {

                                                    }
                                                };
                                                xmlhttp.send(null);
                                            }

                                        }
                                    });
                                    _('Grade' + id).innerHTML = '';
                                }
</script>