• I’m trying to establish my WordPress site in a way that allows me to transfer code from Dreamweaver into a WordPress post without many modifications being necessary. Right now, I’m testing out a randomizing function I made using Javascript. I’ve tested this code in a testing directory so it works online. The button called “Magic” is supposed to start the script.

    The url is found: http://dinoberry.com/obsidian/?p=34

    I will post the code at the end of this post. Originally, I was hoping to apply a css file to an individual post (essentially, only to the contents of a specific area). I’m not as focused on that right now but if someone has a solution that would be great.

    Thanks

    The code is:

    <html>
    <body>
    
    <script type="text/javascript">
    function displaymessage()
    {
    
    var colors = ["agate", "alexandrite", "chrysoberyl", "aquamarine", "beryl", "chrysocolla", "diamond", "emerald", "feldspar", "garnet", "hermatite", "jade", "jasper", "kunzite", "lapis lazuli", "jadeite", "nephrite", "malachite", "obsidian", "peridot", "opal", "pyrite", "quartz", "agate", "amethyst", "citrine", "chalcedony", "onyx", "tiger's-eye", "ruby", "sapphire", "spinel", "sugilite", "tanzanite", "zoisite", "topaz", "turqoise", "tourmaline", "variscite", "zircon", "corundum", "cubic zirconia", "moissanite", "amber", "ammolite", "bone", "coral", "ivory", "nacre", "jet", "pearl", "andalusite", "axinite", "benitoite", "bixbite", "cassiterite", "clinohumite", "iolite", "onyx", "kornerupine", "zeolite",];
    
    var randValue = Math.floor(Math.random() * colors.length);
    document.forms["ninja"].elements["crayons"].value = (colors[randValue]); 
    
    }
    </script>
    
    <form id="ninja">
      <p align="center">
        <textarea name="crayons" cols="50" rows="5" id="crayons"></textarea>
        <br>
      <p align="center">
        <input type="button" value="Magic" onClick="displaymessage()" />
      </p>
    </form>
    
    </body>
    </html>
  • The topic ‘Javascript in Posts Problem’ is closed to new replies.