Passing parameters from a list to sub menu

1

I have a list of users that is formed from a query in the database. And the names are in <a> tag, which consequently when clicked will open a submenu, however I want to pass user data typed into this sub menu. I'm using CodeIgniter.

<?php foreach($usuarios as $usuario): ?>
   <tr>
       <th scope="row">
           <a title="Editar" href="<?php echo base_url() . 'menu/usuario/' . $usuario->id . $usuario->nome; ?>"><?php echo $usuario->nome; ?></a>
       </th>
       <td>
           <span><?php echo $usuario->nome; ?></span>
       </td>
       <th>
          <span><?php echo $usuario->id; ?></span>
       </th>
   </tr>
<?php endforeach ?>
    
asked by anonymous 01.04.2015 / 22:06

1 answer

1

You can use (for example) jQuery to do this:

<a title="Editar" class="campo" href="<?php echo base_url() . 'menu/usuario/' . $usuario->id . $usuario->nome; ?>" data-id="<?php echo $usuario->id; ?>"><?php echo $usuario->nome; ?></a>

...

//jQuery
$(document).ready(function(){
    $('.campo').click(function(){
        $('.campoid-nosubmenu').value();
        $('.camponome-nosubmenu').value();

        $('.campoid-nosubmenu').value($(this).data("id"));
        $('.camponome-nosubmenu').value($(this).value());
    });
});
    
01.04.2015 / 22:21