Support » Plugins » Hacks » Javascript in Posts Problem

  • 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:

    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.


    The code is:

    <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]); 
    <form id="ninja">
      <p align="center">
        <textarea name="crayons" cols="50" rows="5" id="crayons"></textarea>
      <p align="center">
        <input type="button" value="Magic" onClick="displaymessage()" />
  • The topic ‘Javascript in Posts Problem’ is closed to new replies.