• Hoping I can get some help – I don’t know much (or anything) about code, but I am trying to create a name generator tool for my website.

    I found a free piece of code that allowed me to download a name generator javascript code and then cut and pasted names I wanted to generate. I saved the code as a name-generator.js and uploaded it to the root domain of my website.

    I read in the Using Javascript codex that when you want to use javascript on one specific page/post, you put this in:

    <script type="text/javascript" src="/scripts/updatepage.js"></script>
    <script type="text/javascript">
    <!--
    updatepage();
    //--></script>

    I did this in my post, replacing “updatepage.js” with “name-generator.js” but nothing shows up.

    I also do not understand when the codex says

    Make sure that each script is defined by its function name, such as:

    function updatepage(){var m="Page updated "+document.lastMo.......}

    The function used in my javascript is:
    function generator()
    so I replaced the “updatepage()” with “generator()” but I do not know if that makes sense.

    Thank you so much, I’m sorry, really no idea what I am doing!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Hi meggo4all

    Can you share the post where you tried this?

    Is the file name-generator.js in a directory called scripts in the root of your site?

    Thread Starter meggo4all

    (@meggo4all)

    Hi Kessiemeijer – thanks so much for the help. Sorry for the late reply, I was having server issues.

    Yes – I put the name-generator.js file in a scripts directory folder that I created.

    Here is the page where I posted the generator:
    http://www.k9ofmine.com/dog-name-generator-test

    Here is a link to the script I created (using a template):
    http://www.k9ofmine.com/scripts/name-generator.js

    Any help you can offer would be greatly appreciated! As I said, I know very little about code but am hoping to get this name generator working.

    Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Putting Javascript Tool in WordPress Post’ is closed to new replies.