[eluser]Ludovic-r[/eluser]
Hi everyone !
I'm stuck on something that I can't fix by myself
Unfortunately... I need to store a rank from some inputs fields generated by jQuery in my TABLE, let me explain :
When I click on a button I add an input field in my page, each input field generated have an
incremented name (name0, name1 ...) and an
incremented id (item-1, item-2 and so on)
I use the sortable function of jQuery and everything is okay, I drag and drop my fields and they have their order.
I serialize everything and it gives me that :
item[]=0&item;[]=2&item;[]=1&item;[]=3 each field have a rank. Well now I need to store this rank in my DB WITH the field associated (my TABLE look like this :
'id' 'rank' the 'id field is auto incremented)
Here's my code :
THE JS FUNCTION TO ADD FIELDS :
Code:
$(function() {
var item = 'item-';
var i = 0;
var k = 0;
var deletebtn = "<div id='deletebtn'>delete this</div>";
$("#button_add").live("click", function(){
$('#reorder').append("<li id="+ item + i++ +" class='list_item'>" + "<input type='text' name='title"+ k++ +"' value='' kind='title' />" + deletebtn + "</li>");
});
});
Code:
newRank = $("#reorder").sortable("serialize");
$("#rank").val(newRank);
This is linked to an input field to get the serialized value
Code:
<input type="hidden" id="rank" name="rank" value="" />
THE PHP TO $_POST THE INPUT FIELD :
Code:
$rank = $this->input->post('rank');
// THIS WILL GIVE ME THE RESULT : item[]=0&item;[]=2&item;[]=1&item;[]=3
Any idea to store the rank of each field corresponding to their id in my DB ? Any help would be very very appreciated !!
Thanks !