so I think I am a bit lost as to what I am even trying now I'm so tired.
basically I have 4 checkboxes their values are a number.
so lets say my HTML source is like this:
<input class="extra" type="checkbox" name="checks[1]" value="1"/>
<input class="extra" checked="checked" type="checkbox" name="checks[2]" value="2"/>
<input class="extra" type="checkbox" name="checks[3]" value="3"/>
<input class="extra" checked="checked" type="checkbox" name="checks[4]" value="4"/>
I want to post checks[] with jquery post as it would be posted with PHP, I am very new to this and confused with people just saying 'serialize', which then leads to me getting lost using serialize.
checks[1] is empty
check[2] = 2
checks[4] = 4
i want it essentially like that ^ on the other side.
I am serializing it like so:
var post_data = $('input[name^="checks"]:checked').serialize();
post it like so:
$.post('search_item.php', post_data { 'option[]':option, save: form.save.value, item: form.item.value, name: form.i_name.value, desc: form.i_desc.value, text: form.i_text.value },
function(output) {
$('#return2').html(output).show();
});
now accessing it the other side its structured like so:
checks[0] = c
checks[1] = h
checks[2] = e
etc.
so can please someone tell me how this actually works? Because I am exhausted and very confused.
many thanks,
joe
var post_data = $('input[name^="checks"]:checked').serialize();
try $.post('search_item.php', post_data, ...)
you should received the input in the format you want
checks[1] is empty
check[2] = 2
checks[4] = 4