How to write the check box inside the tag jQuery












0















I am creating an e-commerce website and have to display the categories inside li tag checkbox. what I tried so far I wrote below. I couldn't get the output.



I have written inside the li tag like this but it didn't work for me.



<li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>


below I attached the full code.



Form Design(HTML)



 <div align="left">
<li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>




        <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>

</div>


Jquery



function getCategory(){
$.ajax({
type: 'GET',
url: 'get_category.php' ,
dataType: 'JSON',
success: function (data)
{
for (var i = 0; i < data.length; i++)
{
var catname = data[i].catname;
var id = data[i].id;
// $(this).prepend($('<input type="checkbox"/>'));
$('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>');
}
},
error: function (xhr, status, error)
{
console.log(xhr.message)
}

});
}


get_category.php



<?php
include("db.php");

$stmt = $conn->prepare("select id,cat_name,status from category where status = '1' order by id DESC");
$stmt->bind_result($id,$catname,$status);

if ($stmt->execute()) {
while ( $stmt->fetch() ) {
$output = array ("id"=>$id, "catname"=>$catname,"status"=>$status);
}

echo json_encode( $output );
}
$stmt->close();

//}









share|improve this question

























  • I think you are mising the <ul> tag. Try to replace the <div align="left">

    – Fabian
    Nov 16 '18 at 7:12













  • sir it is working if i written only put li tag . like this <li class="list-group-item list-group-item-action" id="categories"></li> . i need to put checkbox inside the li tag how to do this sir

    – Programmer Hari
    Nov 16 '18 at 7:14













  • <ul> <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li> <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></li> </ul> but it didn't work sir

    – Programmer Hari
    Nov 16 '18 at 7:24











  • I am mobile at the moment so I cant test the code, but have you tried closing the input tag </input> some browsers dont like having it non closed when nested like this

    – Jacques Ramsden
    Nov 16 '18 at 7:24













  • <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></input></li>

    – Programmer Hari
    Nov 16 '18 at 7:25
















0















I am creating an e-commerce website and have to display the categories inside li tag checkbox. what I tried so far I wrote below. I couldn't get the output.



I have written inside the li tag like this but it didn't work for me.



<li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>


below I attached the full code.



Form Design(HTML)



 <div align="left">
<li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>




        <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>

</div>


Jquery



function getCategory(){
$.ajax({
type: 'GET',
url: 'get_category.php' ,
dataType: 'JSON',
success: function (data)
{
for (var i = 0; i < data.length; i++)
{
var catname = data[i].catname;
var id = data[i].id;
// $(this).prepend($('<input type="checkbox"/>'));
$('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>');
}
},
error: function (xhr, status, error)
{
console.log(xhr.message)
}

});
}


get_category.php



<?php
include("db.php");

$stmt = $conn->prepare("select id,cat_name,status from category where status = '1' order by id DESC");
$stmt->bind_result($id,$catname,$status);

if ($stmt->execute()) {
while ( $stmt->fetch() ) {
$output = array ("id"=>$id, "catname"=>$catname,"status"=>$status);
}

echo json_encode( $output );
}
$stmt->close();

//}









share|improve this question

























  • I think you are mising the <ul> tag. Try to replace the <div align="left">

    – Fabian
    Nov 16 '18 at 7:12













  • sir it is working if i written only put li tag . like this <li class="list-group-item list-group-item-action" id="categories"></li> . i need to put checkbox inside the li tag how to do this sir

    – Programmer Hari
    Nov 16 '18 at 7:14













  • <ul> <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li> <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></li> </ul> but it didn't work sir

    – Programmer Hari
    Nov 16 '18 at 7:24











  • I am mobile at the moment so I cant test the code, but have you tried closing the input tag </input> some browsers dont like having it non closed when nested like this

    – Jacques Ramsden
    Nov 16 '18 at 7:24













  • <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></input></li>

    – Programmer Hari
    Nov 16 '18 at 7:25














0












0








0








I am creating an e-commerce website and have to display the categories inside li tag checkbox. what I tried so far I wrote below. I couldn't get the output.



I have written inside the li tag like this but it didn't work for me.



<li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>


below I attached the full code.



Form Design(HTML)



 <div align="left">
<li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>




        <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>

</div>


Jquery



function getCategory(){
$.ajax({
type: 'GET',
url: 'get_category.php' ,
dataType: 'JSON',
success: function (data)
{
for (var i = 0; i < data.length; i++)
{
var catname = data[i].catname;
var id = data[i].id;
// $(this).prepend($('<input type="checkbox"/>'));
$('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>');
}
},
error: function (xhr, status, error)
{
console.log(xhr.message)
}

});
}


get_category.php



<?php
include("db.php");

$stmt = $conn->prepare("select id,cat_name,status from category where status = '1' order by id DESC");
$stmt->bind_result($id,$catname,$status);

if ($stmt->execute()) {
while ( $stmt->fetch() ) {
$output = array ("id"=>$id, "catname"=>$catname,"status"=>$status);
}

echo json_encode( $output );
}
$stmt->close();

//}









share|improve this question
















I am creating an e-commerce website and have to display the categories inside li tag checkbox. what I tried so far I wrote below. I couldn't get the output.



I have written inside the li tag like this but it didn't work for me.



<li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>


below I attached the full code.



Form Design(HTML)



 <div align="left">
<li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>




        <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox"></li>

</div>


Jquery



function getCategory(){
$.ajax({
type: 'GET',
url: 'get_category.php' ,
dataType: 'JSON',
success: function (data)
{
for (var i = 0; i < data.length; i++)
{
var catname = data[i].catname;
var id = data[i].id;
// $(this).prepend($('<input type="checkbox"/>'));
$('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>');
}
},
error: function (xhr, status, error)
{
console.log(xhr.message)
}

});
}


get_category.php



<?php
include("db.php");

$stmt = $conn->prepare("select id,cat_name,status from category where status = '1' order by id DESC");
$stmt->bind_result($id,$catname,$status);

if ($stmt->execute()) {
while ( $stmt->fetch() ) {
$output = array ("id"=>$id, "catname"=>$catname,"status"=>$status);
}

echo json_encode( $output );
}
$stmt->close();

//}






php json






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 7:29







Programmer Hari

















asked Nov 16 '18 at 7:06









Programmer HariProgrammer Hari

949




949













  • I think you are mising the <ul> tag. Try to replace the <div align="left">

    – Fabian
    Nov 16 '18 at 7:12













  • sir it is working if i written only put li tag . like this <li class="list-group-item list-group-item-action" id="categories"></li> . i need to put checkbox inside the li tag how to do this sir

    – Programmer Hari
    Nov 16 '18 at 7:14













  • <ul> <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li> <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></li> </ul> but it didn't work sir

    – Programmer Hari
    Nov 16 '18 at 7:24











  • I am mobile at the moment so I cant test the code, but have you tried closing the input tag </input> some browsers dont like having it non closed when nested like this

    – Jacques Ramsden
    Nov 16 '18 at 7:24













  • <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></input></li>

    – Programmer Hari
    Nov 16 '18 at 7:25



















  • I think you are mising the <ul> tag. Try to replace the <div align="left">

    – Fabian
    Nov 16 '18 at 7:12













  • sir it is working if i written only put li tag . like this <li class="list-group-item list-group-item-action" id="categories"></li> . i need to put checkbox inside the li tag how to do this sir

    – Programmer Hari
    Nov 16 '18 at 7:14













  • <ul> <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li> <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></li> </ul> but it didn't work sir

    – Programmer Hari
    Nov 16 '18 at 7:24











  • I am mobile at the moment so I cant test the code, but have you tried closing the input tag </input> some browsers dont like having it non closed when nested like this

    – Jacques Ramsden
    Nov 16 '18 at 7:24













  • <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></input></li>

    – Programmer Hari
    Nov 16 '18 at 7:25

















I think you are mising the <ul> tag. Try to replace the <div align="left">

– Fabian
Nov 16 '18 at 7:12







I think you are mising the <ul> tag. Try to replace the <div align="left">

– Fabian
Nov 16 '18 at 7:12















sir it is working if i written only put li tag . like this <li class="list-group-item list-group-item-action" id="categories"></li> . i need to put checkbox inside the li tag how to do this sir

– Programmer Hari
Nov 16 '18 at 7:14







sir it is working if i written only put li tag . like this <li class="list-group-item list-group-item-action" id="categories"></li> . i need to put checkbox inside the li tag how to do this sir

– Programmer Hari
Nov 16 '18 at 7:14















<ul> <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li> <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></li> </ul> but it didn't work sir

– Programmer Hari
Nov 16 '18 at 7:24





<ul> <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li> <li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></li> </ul> but it didn't work sir

– Programmer Hari
Nov 16 '18 at 7:24













I am mobile at the moment so I cant test the code, but have you tried closing the input tag </input> some browsers dont like having it non closed when nested like this

– Jacques Ramsden
Nov 16 '18 at 7:24







I am mobile at the moment so I cant test the code, but have you tried closing the input tag </input> some browsers dont like having it non closed when nested like this

– Jacques Ramsden
Nov 16 '18 at 7:24















<li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></input></li>

– Programmer Hari
Nov 16 '18 at 7:25





<li ><input class="list-group-item list-group-item-action" type="checkbox" id="categories"></input></li>

– Programmer Hari
Nov 16 '18 at 7:25












2 Answers
2






active

oldest

votes


















1














Try this:



<div><ul id="displayResults"></ul></div>


Then, inside the php file:



function getCategory(){
$.ajax({
type: 'GET',
url: 'get_category.php' ,
dataType: 'JSON',
success: function (data)
{
for (var i = 0; i < data.length; i++)
{
var catname = data[i].catname;
var catid = data[i].id;
var catstatus = data[i].status;
if(catstatus){
$('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true" checked="true"></li>');
}else{
$('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true"></li>');
}

}
},
error: function (xhr, status, error)
{
console.log(xhr.message)
}
});
}





share|improve this answer


























  • <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox" value="1"></li> i tried this data diplayed but checkbox not workin

    – Programmer Hari
    Nov 16 '18 at 7:58











  • What do you mean by not working? When checked, there's no (tick) symbol? Or the value cannot be saved into the database?

    – henry
    Nov 16 '18 at 7:59













  • $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>'); any wrong inside query

    – Programmer Hari
    Nov 16 '18 at 8:02











  • At the .append function, why you use <a> instead of <li>? By the way, can you answer my previous question properly?

    – henry
    Nov 16 '18 at 8:05











  • values store in the database sir.0: {id: 4, catname: "tv", status: 1} 1: {id: 3, catname: "fan", status: 1} 2: {id: 2, catname: "cloth", status: 1} 3: {id: 1, catname: "cap", status: 1} here values are diplaying . jquery errir i think sir

    – Programmer Hari
    Nov 16 '18 at 8:08





















0














I don't see a call to the function getCategory.
Also insert the checkbox attribute in $('#categories').append(.<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');)



Here my code for the checkbox view:



<script>
$(document).ready(function(){

getCategory();


});

function getCategory(){
$.ajax({
type:'GET',
url: 'get_category.php' ,
success: function (data)
{
var res = JSON.parse(data);
for(var i = 0; i < res.length; i++) {
var id = res[i].id;
var catname = res[i].catname;
$('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');
}
},
error: function (xhr, status, error)
{
console.log(xhr.message)
}

});
}


</script>

<div align="left">
<ul class = "list-group">
<li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>

<li class="list-group-item list-group-item-action" id="categories"></li>
</ul>
</div>


Hope this can help you.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333002%2fhow-to-write-the-check-box-inside-the-li-tag-jquery%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Try this:



    <div><ul id="displayResults"></ul></div>


    Then, inside the php file:



    function getCategory(){
    $.ajax({
    type: 'GET',
    url: 'get_category.php' ,
    dataType: 'JSON',
    success: function (data)
    {
    for (var i = 0; i < data.length; i++)
    {
    var catname = data[i].catname;
    var catid = data[i].id;
    var catstatus = data[i].status;
    if(catstatus){
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true" checked="true"></li>');
    }else{
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true"></li>');
    }

    }
    },
    error: function (xhr, status, error)
    {
    console.log(xhr.message)
    }
    });
    }





    share|improve this answer


























    • <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox" value="1"></li> i tried this data diplayed but checkbox not workin

      – Programmer Hari
      Nov 16 '18 at 7:58











    • What do you mean by not working? When checked, there's no (tick) symbol? Or the value cannot be saved into the database?

      – henry
      Nov 16 '18 at 7:59













    • $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>'); any wrong inside query

      – Programmer Hari
      Nov 16 '18 at 8:02











    • At the .append function, why you use <a> instead of <li>? By the way, can you answer my previous question properly?

      – henry
      Nov 16 '18 at 8:05











    • values store in the database sir.0: {id: 4, catname: "tv", status: 1} 1: {id: 3, catname: "fan", status: 1} 2: {id: 2, catname: "cloth", status: 1} 3: {id: 1, catname: "cap", status: 1} here values are diplaying . jquery errir i think sir

      – Programmer Hari
      Nov 16 '18 at 8:08


















    1














    Try this:



    <div><ul id="displayResults"></ul></div>


    Then, inside the php file:



    function getCategory(){
    $.ajax({
    type: 'GET',
    url: 'get_category.php' ,
    dataType: 'JSON',
    success: function (data)
    {
    for (var i = 0; i < data.length; i++)
    {
    var catname = data[i].catname;
    var catid = data[i].id;
    var catstatus = data[i].status;
    if(catstatus){
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true" checked="true"></li>');
    }else{
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true"></li>');
    }

    }
    },
    error: function (xhr, status, error)
    {
    console.log(xhr.message)
    }
    });
    }





    share|improve this answer


























    • <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox" value="1"></li> i tried this data diplayed but checkbox not workin

      – Programmer Hari
      Nov 16 '18 at 7:58











    • What do you mean by not working? When checked, there's no (tick) symbol? Or the value cannot be saved into the database?

      – henry
      Nov 16 '18 at 7:59













    • $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>'); any wrong inside query

      – Programmer Hari
      Nov 16 '18 at 8:02











    • At the .append function, why you use <a> instead of <li>? By the way, can you answer my previous question properly?

      – henry
      Nov 16 '18 at 8:05











    • values store in the database sir.0: {id: 4, catname: "tv", status: 1} 1: {id: 3, catname: "fan", status: 1} 2: {id: 2, catname: "cloth", status: 1} 3: {id: 1, catname: "cap", status: 1} here values are diplaying . jquery errir i think sir

      – Programmer Hari
      Nov 16 '18 at 8:08
















    1












    1








    1







    Try this:



    <div><ul id="displayResults"></ul></div>


    Then, inside the php file:



    function getCategory(){
    $.ajax({
    type: 'GET',
    url: 'get_category.php' ,
    dataType: 'JSON',
    success: function (data)
    {
    for (var i = 0; i < data.length; i++)
    {
    var catname = data[i].catname;
    var catid = data[i].id;
    var catstatus = data[i].status;
    if(catstatus){
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true" checked="true"></li>');
    }else{
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true"></li>');
    }

    }
    },
    error: function (xhr, status, error)
    {
    console.log(xhr.message)
    }
    });
    }





    share|improve this answer















    Try this:



    <div><ul id="displayResults"></ul></div>


    Then, inside the php file:



    function getCategory(){
    $.ajax({
    type: 'GET',
    url: 'get_category.php' ,
    dataType: 'JSON',
    success: function (data)
    {
    for (var i = 0; i < data.length; i++)
    {
    var catname = data[i].catname;
    var catid = data[i].id;
    var catstatus = data[i].status;
    if(catstatus){
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true" checked="true"></li>');
    }else{
    $('#displayResults').append('<li id=cat_'+catid+' class="list-group-item list-group-item-action"><b>'+ data[i].catname + '<b><input id="cat_'+ catid +'" type="checkbox" value="true"></li>');
    }

    }
    },
    error: function (xhr, status, error)
    {
    console.log(xhr.message)
    }
    });
    }






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 16 '18 at 8:30

























    answered Nov 16 '18 at 7:49









    henryhenry

    406




    406













    • <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox" value="1"></li> i tried this data diplayed but checkbox not workin

      – Programmer Hari
      Nov 16 '18 at 7:58











    • What do you mean by not working? When checked, there's no (tick) symbol? Or the value cannot be saved into the database?

      – henry
      Nov 16 '18 at 7:59













    • $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>'); any wrong inside query

      – Programmer Hari
      Nov 16 '18 at 8:02











    • At the .append function, why you use <a> instead of <li>? By the way, can you answer my previous question properly?

      – henry
      Nov 16 '18 at 8:05











    • values store in the database sir.0: {id: 4, catname: "tv", status: 1} 1: {id: 3, catname: "fan", status: 1} 2: {id: 2, catname: "cloth", status: 1} 3: {id: 1, catname: "cap", status: 1} here values are diplaying . jquery errir i think sir

      – Programmer Hari
      Nov 16 '18 at 8:08





















    • <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox" value="1"></li> i tried this data diplayed but checkbox not workin

      – Programmer Hari
      Nov 16 '18 at 7:58











    • What do you mean by not working? When checked, there's no (tick) symbol? Or the value cannot be saved into the database?

      – henry
      Nov 16 '18 at 7:59













    • $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>'); any wrong inside query

      – Programmer Hari
      Nov 16 '18 at 8:02











    • At the .append function, why you use <a> instead of <li>? By the way, can you answer my previous question properly?

      – henry
      Nov 16 '18 at 8:05











    • values store in the database sir.0: {id: 4, catname: "tv", status: 1} 1: {id: 3, catname: "fan", status: 1} 2: {id: 2, catname: "cloth", status: 1} 3: {id: 1, catname: "cap", status: 1} here values are diplaying . jquery errir i think sir

      – Programmer Hari
      Nov 16 '18 at 8:08



















    <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox" value="1"></li> i tried this data diplayed but checkbox not workin

    – Programmer Hari
    Nov 16 '18 at 7:58





    <li class="list-group-item list-group-item-action" id="categories"><input type="checkbox" value="1"></li> i tried this data diplayed but checkbox not workin

    – Programmer Hari
    Nov 16 '18 at 7:58













    What do you mean by not working? When checked, there's no (tick) symbol? Or the value cannot be saved into the database?

    – henry
    Nov 16 '18 at 7:59







    What do you mean by not working? When checked, there's no (tick) symbol? Or the value cannot be saved into the database?

    – henry
    Nov 16 '18 at 7:59















    $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>'); any wrong inside query

    – Programmer Hari
    Nov 16 '18 at 8:02





    $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action">' + '<b>'+ data[i].catname + '<b>' + '</a>'); any wrong inside query

    – Programmer Hari
    Nov 16 '18 at 8:02













    At the .append function, why you use <a> instead of <li>? By the way, can you answer my previous question properly?

    – henry
    Nov 16 '18 at 8:05





    At the .append function, why you use <a> instead of <li>? By the way, can you answer my previous question properly?

    – henry
    Nov 16 '18 at 8:05













    values store in the database sir.0: {id: 4, catname: "tv", status: 1} 1: {id: 3, catname: "fan", status: 1} 2: {id: 2, catname: "cloth", status: 1} 3: {id: 1, catname: "cap", status: 1} here values are diplaying . jquery errir i think sir

    – Programmer Hari
    Nov 16 '18 at 8:08







    values store in the database sir.0: {id: 4, catname: "tv", status: 1} 1: {id: 3, catname: "fan", status: 1} 2: {id: 2, catname: "cloth", status: 1} 3: {id: 1, catname: "cap", status: 1} here values are diplaying . jquery errir i think sir

    – Programmer Hari
    Nov 16 '18 at 8:08















    0














    I don't see a call to the function getCategory.
    Also insert the checkbox attribute in $('#categories').append(.<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');)



    Here my code for the checkbox view:



    <script>
    $(document).ready(function(){

    getCategory();


    });

    function getCategory(){
    $.ajax({
    type:'GET',
    url: 'get_category.php' ,
    success: function (data)
    {
    var res = JSON.parse(data);
    for(var i = 0; i < res.length; i++) {
    var id = res[i].id;
    var catname = res[i].catname;
    $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');
    }
    },
    error: function (xhr, status, error)
    {
    console.log(xhr.message)
    }

    });
    }


    </script>

    <div align="left">
    <ul class = "list-group">
    <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>

    <li class="list-group-item list-group-item-action" id="categories"></li>
    </ul>
    </div>


    Hope this can help you.






    share|improve this answer






























      0














      I don't see a call to the function getCategory.
      Also insert the checkbox attribute in $('#categories').append(.<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');)



      Here my code for the checkbox view:



      <script>
      $(document).ready(function(){

      getCategory();


      });

      function getCategory(){
      $.ajax({
      type:'GET',
      url: 'get_category.php' ,
      success: function (data)
      {
      var res = JSON.parse(data);
      for(var i = 0; i < res.length; i++) {
      var id = res[i].id;
      var catname = res[i].catname;
      $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');
      }
      },
      error: function (xhr, status, error)
      {
      console.log(xhr.message)
      }

      });
      }


      </script>

      <div align="left">
      <ul class = "list-group">
      <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>

      <li class="list-group-item list-group-item-action" id="categories"></li>
      </ul>
      </div>


      Hope this can help you.






      share|improve this answer




























        0












        0








        0







        I don't see a call to the function getCategory.
        Also insert the checkbox attribute in $('#categories').append(.<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');)



        Here my code for the checkbox view:



        <script>
        $(document).ready(function(){

        getCategory();


        });

        function getCategory(){
        $.ajax({
        type:'GET',
        url: 'get_category.php' ,
        success: function (data)
        {
        var res = JSON.parse(data);
        for(var i = 0; i < res.length; i++) {
        var id = res[i].id;
        var catname = res[i].catname;
        $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');
        }
        },
        error: function (xhr, status, error)
        {
        console.log(xhr.message)
        }

        });
        }


        </script>

        <div align="left">
        <ul class = "list-group">
        <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>

        <li class="list-group-item list-group-item-action" id="categories"></li>
        </ul>
        </div>


        Hope this can help you.






        share|improve this answer















        I don't see a call to the function getCategory.
        Also insert the checkbox attribute in $('#categories').append(.<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');)



        Here my code for the checkbox view:



        <script>
        $(document).ready(function(){

        getCategory();


        });

        function getCategory(){
        $.ajax({
        type:'GET',
        url: 'get_category.php' ,
        success: function (data)
        {
        var res = JSON.parse(data);
        for(var i = 0; i < res.length; i++) {
        var id = res[i].id;
        var catname = res[i].catname;
        $('#categories').append('<a href="#" cid= '+ id + ' class="list-group-item list-group-item-action"><input type="checkbox">' + '<b>'+ catname + '<b>' + '</a>');
        }
        },
        error: function (xhr, status, error)
        {
        console.log(xhr.message)
        }

        });
        }


        </script>

        <div align="left">
        <ul class = "list-group">
        <li class="list-group-item list-group-item-action active" ><h4>Category</h4></li>

        <li class="list-group-item list-group-item-action" id="categories"></li>
        </ul>
        </div>


        Hope this can help you.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 16 '18 at 12:07

























        answered Nov 16 '18 at 11:23









        Søren NørupSøren Nørup

        364




        364






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333002%2fhow-to-write-the-check-box-inside-the-li-tag-jquery%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine