javascript - Aggregate values from selected divs -


i'm trying pass values selected divs, ids of divs values want , aggregate textbox, i'm not getting result. want id div, in example div id="thisone" when click. script looks this:

<script> function myfunction(elmnt, clr) {     elmnt.style.backgroundcolor = clr;     document.getelementbyid("allvalues").value = document.getelementbyid(elmnt.value).value; } </script> 

view:

<form method="post" action="<?=base_url()?>index.php/dashboard/test_val">                 <div id="frame">                     <table>                         <tbody>                         <?php                          for($i = 0, $size = count($farm)-1; $i < $size; $i++) {                             if($i == 0)                                  echo '<tr>';                              if($flag == 1){                                 echo '</tr>';                                 echo '<tr>';                                 $flag = 0;                             }                             if($farm[$i]['id_field'] == $farm[$i+1]['id_field']) {                                 echo '<td>';?>                                 <div id="<?php echo $farm[$i]['section_name'] ?>" onclick="myfunction(this, 'red')" style="width:60px; height:60px; border:1px solid #aaaaaa;background:#ccff99">                                 <center><?php echo $farm[$i]['section_name'] ?></center></div>                                 <?php echo '</td>';                             }else                                 $flag = 1;                              if($i == $size - 1)                                 echo '</tr>';                         }?>                         </tbody>                     </table>                 </div>                 <hr>                 <div>                     <label>select fertilizer aplly:</label>                     <select name="choosenfert">                         <?php foreach ($fertilization $row) : ?>                             <option value="<?php echo $row['id'] ?>"> <?php echo $row['type'] ?> </option>                                               <?php endforeach;?>                     </select>                     <br />                      <button>apply fertilizer</button>                     <input type="text" id="allvalues" name="allvalues" hidden>                 </div>             </form> 

controller:

public function test_val(){         $inputdata = $this->input->post("allvalues");         echo $inputdata;     } 

try:

document.getelementbyid("allvalues").value += elmnt.id; 

in function "myfunction".


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -