How convert text in input DOM to be a link in a DOM in HTML












0














I just create a website, that has a table. The table needs to get input from the user. After that, the data need to show inside the table.



Meanwhile, there is a cell on the table, that needs to be input by a text of a link. After user click button "try it". It should show a button "MORE" inside the cell. So that, the user can access the external link by clicking the button.



This is my code:



<tbody>
<tr>
<td data-title='Exhibition'>
Title
</td>
<td data-title='By'>
Name
</td>
<td data-title='Exhibition Date'>
27 Aug 2019
</td>
<td data-title='Location'>
CITY / COUNTRY
</td>
<td class='select'>
<a class='button' href='#'>
MORE
</a>
</td>
</tr>

<!-- <tr id="rows" style="display:none;">
<td data-title='Exhibition'>
<input type="text" name="Exhibition<? $i ?>" />
</td>
<td data-title='By'>
<input type="text" name="By<? $i ?>" />
</td>
<td data-title='Exhibition Date'>
<input type="text" name="Exhibition Date<? $i ?>" />
</td>
<td data-title='Location'>
<input type="text" name="Location<? $i ?>" />
</td>
<td class='select'>
<a class='button' href='#'>
Select
</a>
</td>

</tr> -->

<!-- <input type='text' id='cellOne' />
<input type='text' id='cellTwo' /> -->


<tr id="rows" style="display:none;" class="rows">
<td data-title='Exhibition'>
<input type="text" name="Exhibition<? $i ?>" id='cell1'/>
</td>
<td data-title='By'>
<input type="text" name="By<? $i ?>" id='cell2'/>
</td>
<td data-title='Exhibition Date'>
<input type="text" name="Exhibition Date<? $i ?>" id='cell3'/>
</td>
<td data-title='Location'>
<input type="text" name="Location<? $i ?>"id='cell4'/>
</td>
<td class='select' id='cell5'>
<!-- <a class='button' href='#'>
Select
</a> -->
<input type="text" name="select<? $i ?>"id='cell5'/>
</td>

</tr>

<button id="submitButton" onclick="myFunction()" style="display:none; float:right;">Try it</button>

</tbody>
</table>


and this is the javascript:



<script>
$("#add_new").click(function () {

$('#rows').show();
$('#submitButton').show();
$('#add_new').hide();

});

function myFunction(){

$('#add_new').show();
$('#submitButton').hide();

var table = document.getElementById("maintable");
var row = table.insertRow(1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);

cell1.innerHTML = document.getElementById('cell1').value;
cell2.innerHTML = document.getElementById('cell2').value;
cell3.innerHTML = document.getElementById('cell3').value;
cell4.innerHTML = document.getElementById('cell4').value;
cell5.innerHTML = document.getElementById('cell5').value;

//clear content on last row
resetAllValues();
hideRows();
}

function resetAllValues() {
$('.rows').find('input:text').val('');
}

function hideRows(){
$("#rows").hide();
}
</script>


According to the code, the result is once I click "Submit Exhibition" button, it can add the data well. But I have not succeeded to transfer the input from the user as a link inside the button.



image 1



image 2



image 3



My question is how to make the input table the user become a link inside the button?










share|improve this question



























    0














    I just create a website, that has a table. The table needs to get input from the user. After that, the data need to show inside the table.



    Meanwhile, there is a cell on the table, that needs to be input by a text of a link. After user click button "try it". It should show a button "MORE" inside the cell. So that, the user can access the external link by clicking the button.



    This is my code:



    <tbody>
    <tr>
    <td data-title='Exhibition'>
    Title
    </td>
    <td data-title='By'>
    Name
    </td>
    <td data-title='Exhibition Date'>
    27 Aug 2019
    </td>
    <td data-title='Location'>
    CITY / COUNTRY
    </td>
    <td class='select'>
    <a class='button' href='#'>
    MORE
    </a>
    </td>
    </tr>

    <!-- <tr id="rows" style="display:none;">
    <td data-title='Exhibition'>
    <input type="text" name="Exhibition<? $i ?>" />
    </td>
    <td data-title='By'>
    <input type="text" name="By<? $i ?>" />
    </td>
    <td data-title='Exhibition Date'>
    <input type="text" name="Exhibition Date<? $i ?>" />
    </td>
    <td data-title='Location'>
    <input type="text" name="Location<? $i ?>" />
    </td>
    <td class='select'>
    <a class='button' href='#'>
    Select
    </a>
    </td>

    </tr> -->

    <!-- <input type='text' id='cellOne' />
    <input type='text' id='cellTwo' /> -->


    <tr id="rows" style="display:none;" class="rows">
    <td data-title='Exhibition'>
    <input type="text" name="Exhibition<? $i ?>" id='cell1'/>
    </td>
    <td data-title='By'>
    <input type="text" name="By<? $i ?>" id='cell2'/>
    </td>
    <td data-title='Exhibition Date'>
    <input type="text" name="Exhibition Date<? $i ?>" id='cell3'/>
    </td>
    <td data-title='Location'>
    <input type="text" name="Location<? $i ?>"id='cell4'/>
    </td>
    <td class='select' id='cell5'>
    <!-- <a class='button' href='#'>
    Select
    </a> -->
    <input type="text" name="select<? $i ?>"id='cell5'/>
    </td>

    </tr>

    <button id="submitButton" onclick="myFunction()" style="display:none; float:right;">Try it</button>

    </tbody>
    </table>


    and this is the javascript:



    <script>
    $("#add_new").click(function () {

    $('#rows').show();
    $('#submitButton').show();
    $('#add_new').hide();

    });

    function myFunction(){

    $('#add_new').show();
    $('#submitButton').hide();

    var table = document.getElementById("maintable");
    var row = table.insertRow(1);
    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);
    var cell3 = row.insertCell(2);
    var cell4 = row.insertCell(3);
    var cell5 = row.insertCell(4);

    cell1.innerHTML = document.getElementById('cell1').value;
    cell2.innerHTML = document.getElementById('cell2').value;
    cell3.innerHTML = document.getElementById('cell3').value;
    cell4.innerHTML = document.getElementById('cell4').value;
    cell5.innerHTML = document.getElementById('cell5').value;

    //clear content on last row
    resetAllValues();
    hideRows();
    }

    function resetAllValues() {
    $('.rows').find('input:text').val('');
    }

    function hideRows(){
    $("#rows").hide();
    }
    </script>


    According to the code, the result is once I click "Submit Exhibition" button, it can add the data well. But I have not succeeded to transfer the input from the user as a link inside the button.



    image 1



    image 2



    image 3



    My question is how to make the input table the user become a link inside the button?










    share|improve this question

























      0












      0








      0







      I just create a website, that has a table. The table needs to get input from the user. After that, the data need to show inside the table.



      Meanwhile, there is a cell on the table, that needs to be input by a text of a link. After user click button "try it". It should show a button "MORE" inside the cell. So that, the user can access the external link by clicking the button.



      This is my code:



      <tbody>
      <tr>
      <td data-title='Exhibition'>
      Title
      </td>
      <td data-title='By'>
      Name
      </td>
      <td data-title='Exhibition Date'>
      27 Aug 2019
      </td>
      <td data-title='Location'>
      CITY / COUNTRY
      </td>
      <td class='select'>
      <a class='button' href='#'>
      MORE
      </a>
      </td>
      </tr>

      <!-- <tr id="rows" style="display:none;">
      <td data-title='Exhibition'>
      <input type="text" name="Exhibition<? $i ?>" />
      </td>
      <td data-title='By'>
      <input type="text" name="By<? $i ?>" />
      </td>
      <td data-title='Exhibition Date'>
      <input type="text" name="Exhibition Date<? $i ?>" />
      </td>
      <td data-title='Location'>
      <input type="text" name="Location<? $i ?>" />
      </td>
      <td class='select'>
      <a class='button' href='#'>
      Select
      </a>
      </td>

      </tr> -->

      <!-- <input type='text' id='cellOne' />
      <input type='text' id='cellTwo' /> -->


      <tr id="rows" style="display:none;" class="rows">
      <td data-title='Exhibition'>
      <input type="text" name="Exhibition<? $i ?>" id='cell1'/>
      </td>
      <td data-title='By'>
      <input type="text" name="By<? $i ?>" id='cell2'/>
      </td>
      <td data-title='Exhibition Date'>
      <input type="text" name="Exhibition Date<? $i ?>" id='cell3'/>
      </td>
      <td data-title='Location'>
      <input type="text" name="Location<? $i ?>"id='cell4'/>
      </td>
      <td class='select' id='cell5'>
      <!-- <a class='button' href='#'>
      Select
      </a> -->
      <input type="text" name="select<? $i ?>"id='cell5'/>
      </td>

      </tr>

      <button id="submitButton" onclick="myFunction()" style="display:none; float:right;">Try it</button>

      </tbody>
      </table>


      and this is the javascript:



      <script>
      $("#add_new").click(function () {

      $('#rows').show();
      $('#submitButton').show();
      $('#add_new').hide();

      });

      function myFunction(){

      $('#add_new').show();
      $('#submitButton').hide();

      var table = document.getElementById("maintable");
      var row = table.insertRow(1);
      var cell1 = row.insertCell(0);
      var cell2 = row.insertCell(1);
      var cell3 = row.insertCell(2);
      var cell4 = row.insertCell(3);
      var cell5 = row.insertCell(4);

      cell1.innerHTML = document.getElementById('cell1').value;
      cell2.innerHTML = document.getElementById('cell2').value;
      cell3.innerHTML = document.getElementById('cell3').value;
      cell4.innerHTML = document.getElementById('cell4').value;
      cell5.innerHTML = document.getElementById('cell5').value;

      //clear content on last row
      resetAllValues();
      hideRows();
      }

      function resetAllValues() {
      $('.rows').find('input:text').val('');
      }

      function hideRows(){
      $("#rows").hide();
      }
      </script>


      According to the code, the result is once I click "Submit Exhibition" button, it can add the data well. But I have not succeeded to transfer the input from the user as a link inside the button.



      image 1



      image 2



      image 3



      My question is how to make the input table the user become a link inside the button?










      share|improve this question













      I just create a website, that has a table. The table needs to get input from the user. After that, the data need to show inside the table.



      Meanwhile, there is a cell on the table, that needs to be input by a text of a link. After user click button "try it". It should show a button "MORE" inside the cell. So that, the user can access the external link by clicking the button.



      This is my code:



      <tbody>
      <tr>
      <td data-title='Exhibition'>
      Title
      </td>
      <td data-title='By'>
      Name
      </td>
      <td data-title='Exhibition Date'>
      27 Aug 2019
      </td>
      <td data-title='Location'>
      CITY / COUNTRY
      </td>
      <td class='select'>
      <a class='button' href='#'>
      MORE
      </a>
      </td>
      </tr>

      <!-- <tr id="rows" style="display:none;">
      <td data-title='Exhibition'>
      <input type="text" name="Exhibition<? $i ?>" />
      </td>
      <td data-title='By'>
      <input type="text" name="By<? $i ?>" />
      </td>
      <td data-title='Exhibition Date'>
      <input type="text" name="Exhibition Date<? $i ?>" />
      </td>
      <td data-title='Location'>
      <input type="text" name="Location<? $i ?>" />
      </td>
      <td class='select'>
      <a class='button' href='#'>
      Select
      </a>
      </td>

      </tr> -->

      <!-- <input type='text' id='cellOne' />
      <input type='text' id='cellTwo' /> -->


      <tr id="rows" style="display:none;" class="rows">
      <td data-title='Exhibition'>
      <input type="text" name="Exhibition<? $i ?>" id='cell1'/>
      </td>
      <td data-title='By'>
      <input type="text" name="By<? $i ?>" id='cell2'/>
      </td>
      <td data-title='Exhibition Date'>
      <input type="text" name="Exhibition Date<? $i ?>" id='cell3'/>
      </td>
      <td data-title='Location'>
      <input type="text" name="Location<? $i ?>"id='cell4'/>
      </td>
      <td class='select' id='cell5'>
      <!-- <a class='button' href='#'>
      Select
      </a> -->
      <input type="text" name="select<? $i ?>"id='cell5'/>
      </td>

      </tr>

      <button id="submitButton" onclick="myFunction()" style="display:none; float:right;">Try it</button>

      </tbody>
      </table>


      and this is the javascript:



      <script>
      $("#add_new").click(function () {

      $('#rows').show();
      $('#submitButton').show();
      $('#add_new').hide();

      });

      function myFunction(){

      $('#add_new').show();
      $('#submitButton').hide();

      var table = document.getElementById("maintable");
      var row = table.insertRow(1);
      var cell1 = row.insertCell(0);
      var cell2 = row.insertCell(1);
      var cell3 = row.insertCell(2);
      var cell4 = row.insertCell(3);
      var cell5 = row.insertCell(4);

      cell1.innerHTML = document.getElementById('cell1').value;
      cell2.innerHTML = document.getElementById('cell2').value;
      cell3.innerHTML = document.getElementById('cell3').value;
      cell4.innerHTML = document.getElementById('cell4').value;
      cell5.innerHTML = document.getElementById('cell5').value;

      //clear content on last row
      resetAllValues();
      hideRows();
      }

      function resetAllValues() {
      $('.rows').find('input:text').val('');
      }

      function hideRows(){
      $("#rows").hide();
      }
      </script>


      According to the code, the result is once I click "Submit Exhibition" button, it can add the data well. But I have not succeeded to transfer the input from the user as a link inside the button.



      image 1



      image 2



      image 3



      My question is how to make the input table the user become a link inside the button?







      javascript jquery html






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 20:49









      Agnes PalitAgnes Palit

      1639




      1639
























          0






          active

          oldest

          votes











          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%2f53382428%2fhow-convert-text-in-input-dom-to-be-a-link-in-a-dom-in-html%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f53382428%2fhow-convert-text-in-input-dom-to-be-a-link-in-a-dom-in-html%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

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          Npm cannot find a required file even through it is in the searched directory