javascript - how to get each values in a for loop using codeigniter -
`view page code getting current date , previous 9 dates.how each date form , put each selected date textbox //get each date textbox inside form.date_array controller
<? $numitems = count($date_array)-1; echo $numitems; for($i=0;$i<count($date_array);$i++){?> <?if($i !=$numitems){?> <li> <a href="#" class="dp-item" data-moment="<?echo $date_array[$i]['db_date']?>" title="<?echo $date_array[$i]['title']?>"> <input name="income_date" class="form-control" value="<?echo $date_array[$i]['db_date']?>" type="hidden" /> <span class="dp-date"><?echo $date_array[$i]['dp_day']?><br><?echo $date_array[$i]['dp_date']?></span> <span class="dp-det"><i id="dp-calendar" class="glyphicon glyphicon-calendar"> </i><?echo $date_array[$i]['day']?><br><?echo $date_array[$i]['date']?></span> </a> </li> <?}else{?> <li> <a href="#" class="dp-item dp-selected " data-moment="<?echo $date_array[$i]['db_date']?>" title="<?echo $date_array[$i]['title']?>"> <span class="dp-date" style="display: none;"><?echo $date_array[$i]['dp_day']?><br><?echo $date_array[$i]['dp_date']?></span> <span class="dp-det" style="display: block;"><i id="dp-calendar" class="glyphicon glyphicon-calendar"> </i><?echo $date_array[$i]['day']?><br><?echo $date_array[$i]['date']?></span> </a> </li> <?}}?>
controller
//this date format public function index() { $date_array=array(); $timestamp = time(); $j=9; ($i = 0 ; $i < 10 ; $i++) { // echo date('y-m-d', $timestamp) . '<br />'; //echo date('ds, l f y', $timestamp) . '<br />'; $date_array[$j]['db_date']= date('y-m-d', $timestamp); $date_array[$j]['date']= date('ds, f y', $timestamp); $date_array[$j]['day']= date('l', $timestamp); $date_array[$j]['title']= date('l, ds f y', $timestamp); $date_array[$j]['dp_day']= date('d', $timestamp); $date_array[$j]['dp_date']= date('ds', $timestamp); $timestamp -= 24 * 3600; $j--; }
script
var income_date = document.queryselectorall('.pagination li a'); alert(income_date);
rewrite index funtion of controller & pass array show in view page
public function index() { $data=array(); // declare $data new variable // , assign date_array int $data variable send $data view page $timestamp = time(); $j=9; ($i = 0 ; $i < 10 ; $i++) { // echo date('y-m-d', $timestamp) . '<br />'; //echo date('ds, l f y', $timestamp) . '<br />'; $data['date_array'][$j]['db_date']= date('y-m-d', $timestamp); $data['date_array'][$j]['date']= date('ds, f y', $timestamp); $data['date_array'][$j]['day']= date('l', $timestamp); $data['date_array'][$j]['title']= date('l, ds f y', $timestamp); $data['date_array'][$j]['dp_day']= date('d', $timestamp); $data['date_array'][$j]['dp_date']= date('ds', $timestamp); $timestamp -= 24 * 3600; $j--; } $this->load->view('welcome_message',$data); }
Comments
Post a Comment