locked
How to Run This JavaScript RRS feed

  • Question

  • User974100899 posted

    I keep getting an uncaught reference error 

    SyntaxError: Unexpected end of script 

    and this is my code

    <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/x.y.z/underscore-min.js"></script>
    </head>
    <body>
     
    <div class="container">
      <div class="panel panel-default">
        <div class="panel-body">
        <label>Is this data for a New or Existing Campaign?</label>
        <select id="newOrexist">
          <option value=""></option>
          <option value="new">New</option>
          <option value="existing">Existing</option>
        </select>
        <br>
        <label>Is this Manual Entry or Spreadsheet Import?</label>
        <select id="manualOrspreadsheet" onchange="ShowMoreData()">
          <option value=""></option>
          <option value="manual">Manual</option>
          <option value="spreadsheet">Spreadsheet</option>
        </select>
        <br>
          <label hidden id="lblCamapignName">Please input the campaign name</label>
          <textarea hidden id="txtareaCampaignName" cols="10" rows="1"/>
        </div>
      </div>
    </div>
    
    </body>
    </html>
    
    
    function ShowMoreData() {
      var x = document.getElementById("manualOrspreadsheet").value;
      if (x == "manual")
      {
      	alert('It Manual');
        document.getElementById("lblCamapignName").style.display = 'block';
        document.getElementById("txtareaCampaignName").style.display = 'block';
      }
      if (x == "spreadsheet")
      {
        alert('It spreadhseet');
      }
    }

    Thursday, February 6, 2020 9:01 PM

Answers

  • User475983607 posted

    The <script> tag is missing and the script should be located just before the ending </body> tag.

    <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/x.y.z/underscore-min.js"></script>
    </head>
    <body>
     
    <div class="container">
      <div class="panel panel-default">
        <div class="panel-body">
        <label>Is this data for a New or Existing Campaign?</label>
        <select id="newOrexist">
          <option value=""></option>
          <option value="new">New</option>
          <option value="existing">Existing</option>
        </select>
        <br>
        <label>Is this Manual Entry or Spreadsheet Import?</label>
        <select id="manualOrspreadsheet" onchange="ShowMoreData()">
          <option value=""></option>
          <option value="manual">Manual</option>
          <option value="spreadsheet">Spreadsheet</option>
        </select>
        <br>
          <label hidden id="lblCamapignName">Please input the campaign name</label>
          <textarea hidden id="txtareaCampaignName" cols="10" rows="1"/>
        </div>
      </div>
    </div>
    <script>
    function ShowMoreData() {
      var x = document.getElementById("manualOrspreadsheet").value;
      if (x == "manual")
      {
      	alert('It Manual');
        document.getElementById("lblCamapignName").style.display = 'block';
        document.getElementById("txtareaCampaignName").style.display = 'block';
      }
      if (x == "spreadsheet")
      {
        alert('It spreadhseet');
      }
    }
    </script>
    </body>
    </html>
    
    
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 6, 2020 9:40 PM