Can't seem to get simple Javascript working

I am brand new with RW … just started yesterday. I am interested in adding a basic javascript script to my site. Here is the function that I am trying to implement: https://www.mediacollege.com/internet/javascript/text/count-words.html

I placed the HTML from this site into a Stacks stack. I placed the javascript from site into the Javascript tab of the HTML inspecter … no joy. Then, I placed the javascipt into the Head tab of the HTML inspector, putting tags around the script. Still no joy. In both cases, I examined the page source code and everything looked ok.

What am I missing? Any tips for a newb?

The JS provided on that page looks up elements by ID, but the HTML provided assigns the field a name and not an id. They are not interchangeable. Using ID is correct. They used the correct HTML in their page, but provided incorrect HTML for you to copy. Try this HTML:

<textarea id="inputString" cols="50" rows="4">Text to count</textarea>
<br>
<input type="button" name="Convert" value="Count Words" onClick="countWords();"> 
<input id="wordcount" type="text" value="" size="6">
1 Like

@DLH, that was it!!! Thanks a heap :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.