Tatu Bogdan
Tatu Bogdan

Reputation: 596

How I can send a form POST from a jQuery datepicker

I have this form:

    <div role="tabpanel" class="tab-pane" id="xcell">
        <div class = "row">
            <div class = "col-md-7">
                <form method = "POST" action = "<?php echo base_url('Usercontroller/getXcell') ?>">
                    <div class="form-group">
                        Start: <input id ="startdate" type ="text" size = "8"/>
                    </div>
                    <div class="form-group">
                        Sfarsit: <input id ="enddate" type ="text" size = "8"/>
                    </div>
                <button type="submit" class="btn btn-default btn-success">Genereaza xcell</button>
                
                </form>
    </div>
        </div>            
            </div>

And this is the javascript calendar:

$(document).ready(function(){
$('#startdate').datepicker({
    startdate : $(this).val()
});
$('#enddate').datepicker({});
});

I was trying with this startdate : $(this).val(), but it will give a empty result. This is the function where I send data:

public function getXcell() {
    $data= $this->input->post();
    var_dump($data);

}

I'm using codeigniter, I want to send the inputs that are selected in Start and Sfarsit to my php function to work with. Thanks

Upvotes: 1

Views: 413

Answers (1)

Nerea
Nerea

Reputation: 2157

You forgot to add name attribute in your form fields

 <div class="form-group">
     Start: <input id ="startdate" type ="text" size = "8" name="startdate"/>
 </div>
 <div class="form-group">
       Sfarsit: <input id ="enddate" type ="text" size = "8" name="enddate" />
 </div>

Upvotes: 1

Related Questions