I use ajax and jquery to append the uploaded image div with checkbox to the thumbnails div which located inside the form, then I when I click the "move marked to set" button it should direct me to the viewset.php page, but I can't get the value from the checkbox, what did I do wrong, can anyone help, thanks!
here is my jquery ajax code
$('#thumbnails').append('<div id="imagediv' + str_idnum + '" style="width:520px;border: 2px solid #aaa;text-align:left;padding:20px;margin- bottom:20px;"><div>开发者_StackOverflow中文版<img src="' + response + '" style="padding:10px; margin-right:20px; border-bottom: 2px solid #ccc;border-left: 2px solid #ccc;border-top: 2px solid #ddd; border-right: 2px solid #ddd;" id="imageid' + str_idnum + '" align="left"/></div"><div class="descriptionwrapper" style="border: 0px solid #aaa;"><textarea cols="40" rows="3" id="textarea' + str_idnum + '" onClick="SelectAll(\'textarea' + str_idnum + '\')" align="left" style="resize:none;">Optional description goes here...</textarea><br /><input type="checkbox" style="" name="check[]" value="checked" id="check' +str_idnum + '"/>Mark<br /><br /><br /></div></div>').fadeIn();
here is my html code
<form id ="complicated" method = 'post' action = 'viewset.php'>
<div class="fancybuttonwrapper" style="margin-left:480px;">
<input type="submit" class="form_button" id="movetoset" value=" Move Marked to Set"></div>
<div class="images" id="thumbnails">
</div>
</form>
here is part of my php code:
$check = $_POST['check'];
$N = count($check);
for($i=0; $i < $N; $i++)
{
echo( $check[$i] . " ");
}
You're only posting the DOM manipulation. If you edit your question and add the actual AJAX call I'd be more than happy to help you out.
What do you mean to get value from the checkbox? If you would like to know if checkbox is checked or not, you can use this example.
In this example When you check each checkbox they will toogle #ToggleDivId
//HTML
<input type="checkbox" onclick="checkIt(this);" name="check[]" value="checked" id="check' +str_idnum + '"/>
//JS
function checkIt(objectt) {$('#ToggleDivId').fadeToggle(objectt.checked);}
Hope it helps...
精彩评论