0

I have a custom SharePoint list form where I would like to have country names(from another list) in one row with a check box in front of each row. On checking of any check box in front of country name, a text box should be enabled for each country where user can write the city name. I can get the country name using rest api and get the array of countries. Now how to implement the check box and city functionality?? Dynamically I need to have check box and a td where this text box should appear for number of countries called. Please advice...sharepoint 2013 client side javascripts/ jquery.

Table
Country name1 □ ______
Country name2 ■ Sydney

0

To get the checkbox in front of the country Name you can do like this:

You can either use REST or SPServices for this, I have done this using SPServices,

$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Country List",
    completefunc: function (xData, Status) {
    if(Status == 'success' )
    {
        $(xData.responseXML).SPFilterNode("z:row").each(function()
        {
            var value= $(this).attr("ows_ID");
            var text = $(this).attr("ows_Title");
            CountryArray.push({
                            title: text,
                            id: value
                        });
             $("BoxIDToAppendControl").append ( "<input id='chk_" + value + "' type='checkbox' value='" + value + "' onchange='GenerateTextBox()'/><label for='chk_" + value + "'>" +Conuntry Name + "</label>" );           

        });
    }
  }
});

Now In GenerateTextBox function you can write the following code

$(container).append('<input type=text class="input" id=tb' + iCnt + ' ' +
                            'value="Text Element ' + iCnt + '" />');

Hope this helps

  • No SPServices. SP Services is not recommended for our project. – ankit Aug 10 '15 at 6:30
  • I said you can use REST api as well, I used SPService in my solution, you can use whatever you want and fill that country array accordingly, or else can directly traverse the data[] array of REST results – Vishwas Goswami Aug 10 '15 at 6:33
  • Did your question got solved? – Vishwas Goswami Aug 13 '15 at 6:32
  • Yeah did it...It was nt that difficult as I thought of..binder the html using rest services...It worked – ankit Aug 30 '15 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.