You must Sign In to post a response.
  • Category: JavaScript

    The code is not working want to know how to rectify it

    <script src="Script/jquery-1.11.3.min.js"></script>
    $(document).ready(function () {
    $("#btn1").click(function () {
    $v = $("#txt").val();
    for (i = 0; i < $v; i++) {
    var box = $('<input type="checkbox" class="chkbx" name="chkbx" value="Option' + i + '">Option ' + i + '<br/>');

    $(document).on("change", ".chkbx", function () {
    var selected = [];
    $(".chkbx:checked").each(function () {
    $("#show").val(selected.join(", "));
    <td><input type="text" id="txt" name="text" /></td>
    <td><button id="btn1">Create</button></td>
    <td><div id="display"></div></td>
    <td><input type="text" id="show" name="show" placeholder="Display Selection.."/></td>

  • #763856
    I think you did not close the option box

    Can you check and let me know whether is it working or not?

    var box = $('<input type="checkbox" class="chkbx" name="chkbx" value="Option' + i + '"/>Option ' + i + '<br/>');

    By Nathan
    Direction is important than speed

  • #763857
    No still its not working the click event doesn't fire ,when clicked directly breakpoint goes to javascript file

    Delete Attachment

  • #763867
    Remove all code from '$("#btn1").click(function ()' and give alert in jQuery to check if code flow properly, I think opetion button give you error
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #763889
    Hai Priyanka,
    It seems that some other script is clashing and the control is not getting to this script.
    You can try by moving

    <script src="Script/jquery-1.11.3.min.js"></script>

    To the below of your script.
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #763925


    Check your references this line correct or not

    <script src="Script/jquery-1.11.3.min.js"></script>

    just put one alert box only inside document ready working or not then you try step by step then you can easily find the issues.

    Name : Dotnet Developer-2015
    Email Id :

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #764143
    Hi Priyanka,

    Just replace your for loop declaration with following line:

    for (i = 0; i < $v.length; i++)

    because $v holds text inputted in textbox with id="txt" so it will be a string of characters, so you have to iterate it with regards to its each and every character.

    Hope this will help you.

    Shashikant Gurav

  • Sign In to post your comments