Trouble Creating Javascript Tool in WordPress Page
-
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.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-testHere is a link to the script I created (using a template):
http://www.k9ofmine.com/scripts/name-generator.jsAs you can see, currently clicking the “make name” button results in no action or result.
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 so much!
The topic ‘Trouble Creating Javascript Tool in WordPress Page’ is closed to new replies.