Hello,
I want to pass value through AJAX using checkboxes. but i wanted to add one more condition here and that is if it is already marked then go to one file(deletion) or if its unmarked go to different file and that is to be insertion file.
Here is my code
php
<li style="list-style:none;"><span><input type="checkbox" name="checkbox[]" value="<?=$fruitname?>" id="<?=$fruitname?>" checked="checked" <?php if($fruitname !=''){ echo "checked=\\"true\\""; }?> onclick="javascript:return insert1('<?=$fruitname?>');">
<?=$fruitname;?></span></li></ul>
JS
function insert1(fruitname){
alert(fruitname);
if (fruitname.checked == 1)
{
alert("Thank You");
http.open('get', 'deletelist.php?fruitname='+fruitname);
}
else{
http.open('get', 'insert_try.php?fruitname='+fruitname);
alert("You didn't check it! Let me check it for you.")
fruitname.checked = 1;
}}
Can anyone please tell ,is this the right method to do this?
Thanks in advance.