Passing parameters from a list to sub menu

Asked

Viewed 75 times

1

I have a list of users that is formed from a query in the database. And the names are tag <a>, which consequently when clicked will open a submenu, but I want to pass the data of the users typed into this sub menu. I’m using the 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 ?>

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());
    });
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.