-1

I am very new to programming , And I had written the code to create the "input control" . And I am able to make it , But I need to place the input control in html table row "txtHTML = txtHTML + "Place the created input control here" + "";

can any one please help me how can I do it

<button onclick="myFunction()">Try it</button>
 <table id="tblCustomListData" border="1" width="100%" style="overflow-x:auto;">
              <thead>
                     <tr class="bgcolorgray">
                        <th>Sno</th>
                        <th >Current DR</th>
                     </tr>
                </thead>
            </table>
</div >
<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">



function myFunction() {


var txtHTML = "";
$('#tblCustomListData tbody').html('');


var x = document.createElement("INPUT");
x.setAttribute("type", "text");
x.setAttribute("id", "uniqueIdentifier");
x.setAttribute("value", "Hello!");
document.body.appendChild(x);



  txtHTML = txtHTML + "<tr>";
     txtHTML = txtHTML + "<td>";
     txtHTML = txtHTML + "Place the created input control here"+ "</a>";
     txtHTML = txtHTML + "</td>";
  txtHTML = txtHTML + "</tr>";

  $("#tblCustomListData").append(txtHTML);

  }
</script>


</body>
</html>
  • This is not the correct forum for a basic coding question. You need to explain how this relates to Sharepoint. – Tally Mar 15 '18 at 8:40
0

It does not look like a SharePoint-related question, but still. I've modified your code a bit:

<button id='tryItButton' >Try it</button>
<table id="tblCustomListData" border="1" width="100%" style="overflow-x:auto;">
          <thead>
                 <tr class="bgcolorgray">
                    <th>Sno</th>
                    <th >Current DR</th>
                 </tr>
            </thead>
        </table>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">

$(function(){
  document.getElementById ("tryItButton").addEventListener ("click", myFunction, false);
  function myFunction() {
    $('#tblCustomListData tbody').html('');
    var txtHTML =  `<tr>
                    <td>
                        <input type='text' id='uniqueIdentifier' value='hello' />
                    </td>
                </tr>`;

  $("#tblCustomListData").append(txtHTML);

  }
});

</script>

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.