通过使用codeigniter和javascript选择下拉列表来填充输入框

时间:2018-08-06 17:46:49

标签: javascript codeigniter

This is the form looks like to visualize the problem

我正在尝试通过选择月份来填充带有开始日期和结束日期的表单,但是它不起作用...请帮助我如何解决此问题。提前非常感谢您

PS。我正在使用codeigniter 3

Month_table

|---------|------------------|------------------|
|  Months | start_date       | end_date         |
|---------|------------------|------------------|
|   June  |   06-01-2018     | 06-31-2018       |
|---------|------------------|------------------|
|   July  |   07-01-2018     | 07-31-2018       |
|---------|------------------|------------------|

我的Java脚本

   function GetDynamicTextBox(value) {
    var row = "";
     row += '<div class="form-group app">';
     row += '<input type="hidden" name="i[]" value="' + value + '"/>';
     row += '<input type="hidden" name="row_id_' + value + '" value="0"/>';
     row += '<div class="col-md-12">';
     row += '<div class="form-group row">';
     row += '<div class="col-md-3">';
     row += '<select  id="month_id_' + value + '" name="month_id_' + value + '" class="form-control" >';
     <?php
       foreach ($monthList as $month) {
     ?>
     row += '<option value="<?php echo $month['id'] ?>"><?php echo $month['months'] ?></option>';
    <?php
    $count++;
     }
    ?>
    row += '</select>';
    row += '</div>';

    row += '<div class="col-md-2">';
    row += '<input id="sdateCell" readonly="readonly" name="sdateCell" placeholder="" type="text" class="form-control"  value="<?php echo set_value('sdateCell'); ?>" />';
    row += '</div>';

    row += '<div class="col-md-2">';
    row += '<input id="edateCell" name="edateCell" readonly="readonly" placeholder="" type="text" class="form-control"  value="<?php echo set_value('edateCell'); ?>" />';
    row += '</div>';

    row += '<div class="col-md-3">';
    row += '<input id="amountCell" name="amountCell" placeholder="" type="text" class="form-control"  value="<?php echo set_value('amountCell'); ?>" />';
    row += '</div>';

    row += '<div class="col-md-1">';
    row += '<input id="penaltyCell" name="penaltyCell" placeholder="" type="text" class="form-control"  value="<?php echo set_value('penaltyCell'); ?>" />';
    row += '</div>';

    row += '<div class="col-md-1"><button id="btnRemove" style="" class="btn btn-sm btn-danger pull-right" type="button"><i class="fa fa-trash"></i></button></div>';
    row += '</div>';
    row += '</div>';
    row += '</div>';
    return row;
}

0 个答案:

没有答案