2 Replies Latest reply: Nov 3, 2014 5:19 AM by Wickedhand RSS

    Javascript written in Dreamweaver behaves different when inserted in Muse

    Wickedhand Community Member

      I have a simple javascript list that is written in Dreamweaver and works as expected but when I copy & paste that exact javascript into the -Object-insert html section in Muse the outcome is different.

      Is there a place I can go to research on what I need to do different for that code to behave properly in Muse? I am not understanding what I need to change or do different.

      Below is the code I got to work in Dreamweaver:

       

      <!doctype html>

      <html>

      <head>

      <meta charset="utf-8">

      <title>list</title>

      <script type="text/javascript">

      function fixTheList(){

      var msg = "";

      var msg = "";

      if (document.getElementById("appleQty").value > 0) {

      msg += "Apples   ";

      msg +=document.getElementById("appleQty").value;

      msg += "<br>";

      }

      if (document.getElementById("orangesQty").value > 0) {

      msg += "Oranges   ";

      msg +=document.getElementById("orangesQty").value;

      msg += "<br>";

      }

      if (document.getElementById("tangerineQty").value > 0) {

      msg += "Tangerines   ";

      msg +=document.getElementById("tangerineQty").value;

      msg += "<br>";

      }

      if (document.getElementById("kiwiQty").value > 0) {

      msg += "Kiwis   ";

      msg +=document.getElementById("kiwiQty").value;

      msg += "<br>";

      }

      if (document.getElementById("pearsQty").value > 0) {

      msg += "Pears   ";

      msg +=document.getElementById("pearsQty").value;

      msg += "<br>";

      }

      if (document.getElementById("grapesQty").value > 0) {

      msg += "Grapes   ";

      msg +=document.getElementById("grapesQty").value;

      msg += "<br>";

      }

      if (document.getElementById("canteloupeQty").value>0) {

      msg += "Canteloupes   ";

      msg+=document.getElementById("canteloupeQty").value;

      msg += "<br>";

      }

      if (document.getElementById("strawberryQty").value>0) {

      msg += "Strawberry   ";

      msg+=document.getElementById("strawberryQty").value;

      msg += "<br>";

      }

      document.getElementById("outputDiv").innerHTML = msg;

      }

      </script>

      </head>

      <body>

      <div id="outputDiv">

      <table>

       

        <tr>

        <td>Item</td>

        <td>Quantity</td>

        </tr>

        <tr>

        <td>Apples</td>

        <td><input type="text" size="3" id="appleQty"></td>

        </tr>

        <tr>

        <td>Oranges</td>

        <td><input type="text" size="3" id="orangesQty"></td>

        </tr>

        <tr>

        <td>Tangerines</td>

        <td><input type="text" size="3" id="tangerineQty"></td>

        </tr>

        <tr>

        <td>Kiwi</td>

        <td><input type="text" size="3" id="kiwiQty"></td>

        </tr>

        <tr>

        <td>Pears</td>

        <td><input type="text" size="3" id="pearsQty"></td>

        </tr>

        <tr>

        <td>Grapes</td>

        <td><input type="text" size="3" id="grapesQty"></td>

        </tr>

        <tr>

        <td>Cantaloupe</td>

        <td>

        <input type="text" size="3" id="canteloupeQty">

        </td>

        </tr>

        <tr>

        <td>Strawberry</td>

        <td><input type="text" size="3" id="strawberryQty">

        </td>

        </tr>

        </table>

        <input type="button" value="Stack" onclick="fixTheList();">

        

        

      </div>

      </body>

      </html>

        • 1. Re: Javascript written in Dreamweaver behaves different when inserted in Muse
          VivekPassan Adobe Employee

          Hello,

           

           

          Only difference I see is with the CSS properties of Input tag.

          You can define the style for these tag by adding few lines of code right below <title> tag in the code you are pasting in Object > Insert HTML.

          For an example you can add codes mentioned below

           

          <style type="text/css">

            input {

              border: thin solid #AAA2A3;

              margin-bottom: 7px;

              margin-left: 9px;

          }

            </style>

           

          As per your requirement you can edit them.

           

          One more advice. Break your codes in to 3 part, Scripts tag, Style tag and Div tag in body.

          Insert Div tag in body in Object > Insert HTML

          Insert Scripts tag, Style tag in Page > Page Properties >Metadata > HTML for <head>

          This will help you avoid any unexpected behavior in preview when you have more stuff inserted in Muse Page.

           

          1. Script tag (Insert it in Page > Page Properties >Metadata > HTML for <head>)

          <script type="text/javascript">

          function fixTheList(){

          var msg = "";

          var msg = "";

          if (document.getElementById("appleQty").value > 0) {

          msg += "Apples   ";

          msg +=document.getElementById("appleQty").value;

          msg += "<br>";

          }

          if (document.getElementById("orangesQty").value > 0) {

          msg += "Oranges   ";

          msg +=document.getElementById("orangesQty").value;

          msg += "<br>";

          }

          if (document.getElementById("tangerineQty").value > 0) {

          msg += "Tangerines   ";

          msg +=document.getElementById("tangerineQty").value;

          msg += "<br>";

          }

          if (document.getElementById("kiwiQty").value > 0) {

          msg += "Kiwis   ";

          msg +=document.getElementById("kiwiQty").value;

          msg += "<br>";

          }

          if (document.getElementById("pearsQty").value > 0) {

          msg += "Pears   ";

          msg +=document.getElementById("pearsQty").value;

          msg += "<br>";

          }

          if (document.getElementById("grapesQty").value > 0) {

          msg += "Grapes   ";

          msg +=document.getElementById("grapesQty").value;

          msg += "<br>";

          }

          if (document.getElementById("canteloupeQty").value>0) {

          msg += "Canteloupes   ";

          msg+=document.getElementById("canteloupeQty").value;

          msg += "<br>";

          }

          if (document.getElementById("strawberryQty").value>0) {

          msg += "Strawberry   ";

          msg+=document.getElementById("strawberryQty").value;

          msg += "<br>";

          }

          document.getElementById("outputDiv").innerHTML = msg;

          }

          </script>

          2. Style Tag (Insert it in Page > Page Properties >Metadata > HTML for <head>)

           

          <style type="text/css">

            input {

              border: thin solid #AAA2A3;

              margin-bottom: 7px;

              margin-left: 9px;

          }

            </style>

           

          3. Div tag in body (Insert in Object > Insert HTML)

           

          <div id="outputDiv">

          <table>

           

            <tr>

            <td>Item</td>

            <td>Quantity</td>

            </tr>

            <tr>

            <td>Apples</td>

            <td><input type="text" size="3" id="appleQty"></td>

            </tr>

            <tr>

            <td>Oranges</td>

            <td><input type="text" size="3" id="orangesQty"></td>

            </tr>

            <tr>

            <td>Tangerines</td>

            <td><input type="text" size="3" id="tangerineQty"></td>

            </tr>

            <tr>

            <td>Kiwi</td>

            <td><input type="text" size="3" id="kiwiQty"></td>

            </tr>

            <tr>

            <td>Pears</td>

            <td><input type="text" size="3" id="pearsQty"></td>

            </tr>

            <tr>

            <td>Grapes</td>

            <td><input type="text" size="3" id="grapesQty"></td>

            </tr>

            <tr>

            <td>Cantaloupe</td>

            <td>

            <input type="text" size="3" id="canteloupeQty">

            </td>

            </tr>

            <tr>

            <td>Strawberry</td>

            <td><input type="text" size="3" id="strawberryQty">

            </td>

            </tr>

            </table>

            <input type="button" value="Stack" onclick="fixTheList();">

            

            

          </div>

           

           

          Regards

          Vivek