admin管理员组

文章数量:1389796

I need to add date to the form input field, but in codeigniter it is not working,here is my code in view, I don't know why it is not working, I have link web links also. it is only not working in codeigniter.this page is loaded using ajax.I think it would be the reason for the problem,how can I fix it????

<script src=".11.1/jquery.min.js"></script>
<link rel="stylesheet" href=".10.0/themes/base/jquery-ui.css" />
<script src=".8.3.js"></script>
<script src=".10.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>


<div id="content">

 <h2>Payment Details.</h2>
<?php
          $this->load->helper('form');
          $attributes = array('method'=>'post','name'=>'payments','id'=>'payments');
          echo form_open_multipart('',$attributes);?>
    <?php //echo form_open_multipart('payments/insert_payment');?>
    <label>Payee Name: </label> <?php echo form_input('payee_name');?><br/><br/>

    <label>Address: </label> <?php echo form_input('address');?><br/><br/>

    <label>Account No: </label> <?php echo form_input('account_no');?><br/><br/>

    <label>Bank Name: </label> <?php echo form_input('bank_name');?><br/><br/>

    <label>Branch: </label> <?php echo form_input('branch');?><br/><br/>

    <label>Amount: </label> <?php echo form_input('amount');?><br/><br/>
    <label>Pick a Check Date: </label> <?php
                    $data = array(
                      'name'=> 'check_date',
                      'id' => 'datepicker',
                      'placeholder' => 'date',
                    );
echo form_input($data);?><br/><br/>

    <label>Check Number: </label> <?php echo form_input('check_number');?><br/><br/>        

    <input type="submit" name="submit" value="Next"/>
<?php echo form_close(); ?>

I need to add date to the form input field, but in codeigniter it is not working,here is my code in view, I don't know why it is not working, I have link web links also. it is only not working in codeigniter.this page is loaded using ajax.I think it would be the reason for the problem,how can I fix it????

<script src="http://ajax.googleapis./ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://code.jquery./ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery./jquery-1.8.3.js"></script>
<script src="http://code.jquery./ui/1.10.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>


<div id="content">

 <h2>Payment Details.</h2>
<?php
          $this->load->helper('form');
          $attributes = array('method'=>'post','name'=>'payments','id'=>'payments');
          echo form_open_multipart('',$attributes);?>
    <?php //echo form_open_multipart('payments/insert_payment');?>
    <label>Payee Name: </label> <?php echo form_input('payee_name');?><br/><br/>

    <label>Address: </label> <?php echo form_input('address');?><br/><br/>

    <label>Account No: </label> <?php echo form_input('account_no');?><br/><br/>

    <label>Bank Name: </label> <?php echo form_input('bank_name');?><br/><br/>

    <label>Branch: </label> <?php echo form_input('branch');?><br/><br/>

    <label>Amount: </label> <?php echo form_input('amount');?><br/><br/>
    <label>Pick a Check Date: </label> <?php
                    $data = array(
                      'name'=> 'check_date',
                      'id' => 'datepicker',
                      'placeholder' => 'date',
                    );
echo form_input($data);?><br/><br/>

    <label>Check Number: </label> <?php echo form_input('check_number');?><br/><br/>        

    <input type="submit" name="submit" value="Next"/>
<?php echo form_close(); ?>

Share Improve this question edited Aug 4, 2014 at 3:46 user3840485 asked Jul 30, 2014 at 6:29 user3840485user3840485 5,0853 gold badges22 silver badges22 bronze badges 1
  • 1 check console for any error – Confused Commented Jul 30, 2014 at 6:40
Add a ment  | 

6 Answers 6

Reset to default 3

You are trying to add two jquery files with different versions

thats why the datepicker is confused which jquery version can be used

please add jQuery.noConflict() before the document.ready function

Hope this helps :)

<script>
jQuery.noConflict();
$(function() {
$( "#datepicker" ).datepicker();
});
</script>

Debug as following

1> Check console.

2> Use inspect element for actual Id ( lots of frameworks changed it internally).

3> Try to put $( "#datepicker" ).datepicker(); at end of file

Datepicker is not working because #datepicker didn't exist yet. You could make this work by moving ('#datepicker').datepicker() to after the point in the code where it(#datepicker) is created.

You are adding date picker to the id

$( "#datepicker" ).datepicker();

But where is this Id. You should add datepiker to the view where the id is available and add the respective javascript file also

I saw alot of problems

  1. save the style sheet inside css folder(optional) your css should inside your ci folder
  2. your href in css is not the right code, if your linking css do the code below

     <link rel="stylesheet" href="<?php echo base_url();?>css/style.css" />`
    

make sure your base_url is correct. To see if this correct try to echo base_url();

hope this help you

View:

$this->load->helper(array('form')); 

Controller:

function datepicker(){
    $this->load->view('datepicker');
}

jQuery:

$(function() {
$( "#datepicker" ).datepicker();
});

本文标签: javascriptCodeigniter Date picker is not workingStack Overflow