I hope that this question is not useless ! but seriously , it is a problem for me .
when I want to build a user interface in a web application to (add, delete ,edit ) something I use HTML forms + hidden inputs to store some values such as "user id" to be deleted,edited ..
I want to build the same interface using just ” anchors + span + div ” insteand of “hidden inputs” . when I write the javascript code that handles “onAdd ,onDelete and onEdit” events I need to know what will be deleted ? what is the id that will be kicked out from my database ?
The question is , how to store this ID in my html tags without using hidden inputs ?
what I’m using is something like this :
<div id="userid_133421" >
<span>Name</span>
<a id="onDelete">Delete</a>
<a id="onEdit">Edit</a>
</div>
$("#onDelete").click(function({
user_id = $(this).parent().attr('id').substring($(this).attr('id').indexOf('_')+1);
$.post('index.php?component=user&action=remove&user_id=' + user_id, function(data){
});
}));
I checked some websites such as Dropbox , and I found that they don’t use this technique to store values (such as file id) , and even more they don’t use classic hidden inputs to do that!
I just want to know how do you manage your code to choose the best way ? 🙁
If you are using JQuery, why not use the
data()function to store information?