Happy MMXVIII new year or JavaScript in WP post

By | January 14, 2018

This is the first my post in 2018. The main goal of this post is to check how javascript code embedded into WP post works. The javascript code which is used in this post may be downloaded from here. It is pure javascript impementation without jQuery or other libraries. The purpose of the code is to convert Roman numbers into decimal ones and back. I hope you know at least a bit about Roman numerals, if not read the following Wikipedia article. Now time to verify how my convertor works, enter some decimal number into text box, for example your DOB, and click on “Convert” button.

Enter Decimal or Roman Number:


So javascript added into WP post works without problem. The current post arrangement looks like:

Javascript code

<script type="text/javascript">



Enter Decimal or Roman Number: <input type="text" id="digit" />
<br /><br /><br />
<input type="button" value="Convert" onclick="javascript:convert()" />
<span id="result">Result: </span>

Google Ad


The JavaScript code is located in the beginning of the post and it is totally invisible. The current JavaScript code is accessible only by current post, if you want that JavaScript functions are used from different pages of your blog place the code inside of header.php or footer.php files.
Now a little about Roman numeral symbol encoding. To represent roman numeral I am using ASCII symbols: I, V, X, L, C, D, and M. However some Roman numbers have its own representation in Unicode:

Code: x2160 x2161 x2162 x2163 x2164 x2165 x2166 x2167 x2168 x2169 x216a x216b x216c x216d x216e x216f

At the end of the article I put the link to the source code of Roman-Decimal convertor written in C++.

Leave a Reply

Your email address will not be published. Required fields are marked *