Caesar cipher implementation I am not very familiar with JavaScript and I'am a little confused with the object oriented peculiarities of it. I am trying to create a Caesar shift using the concepts of objects, methods and properties in JavaScript. I am using an HTML form to take input from user and OnClick return the encoded cipher text to user. This is what I have. I'm pretty much sure about my logic but I guess my object creation and method calls fall through. Am I doing it right?

&lt;head&gt;
&lt;script&gt;
function Caesar(order){
this.order = order;
this.encode = encode;
function encode(input){
this.output = '';
for (var i = 0; i &lt; input.length; i++) {
var this.c = input.charCodeAt(i);
if      (this.c &gt;= 65 &amp;&amp; this.c &lt;=  90) this.output += String.fromCharCode((this.c - 65 + this.order) % 26 + 65);  // Uppercase
else if (this.c &gt;= 97 &amp;&amp; this.c &lt;= 122) this.output += String.fromCharCode((this.c - 97 + this.key) % 26 + 97);  // Lowercase
else   this.output += input.charAt(i);    
}
return answer.innerHTML= output;
 } 
&lt;/script&gt;&lt;/head&gt;
&lt;body&gt;

&lt;form&gt;
Enter Plaintext : &lt;input type = "text" name = "plaintext" id = "plaintext"&gt; 
Enter Shift:      &lt;input type = "text" name = "shift" id = "shift"&gt;&lt;br&gt; --How do I get the input from here and create my caesar object and pass the constructor the shift from this text box?
&lt;input type="button" value="Encode" onclick ="encode()"&gt; --How do I call the encode() method with input from the plaintext text box?  
&lt;/form&gt;
&lt;/body&gt;&lt;/html&gt;
Your code is reviewable, even if it does not work, from a once over:


Indent your code (!!), this is bad:

function Caesar(order){
this.order = order;
this.encode = encode;
function encode(input){
this.output = '';
for (var i = 0; i &lt; input.length; i++) {
var this.c = input.charCodeAt(i);
if      (this.c &gt;= 65 &amp;&amp; this.c &lt;=  90) this.output += String.fromCharCode((this.c - 65 + this.order) % 26 + 65);  // Uppercase
else if (this.c &gt;= 97 &amp;&amp; this.c &lt;= 122) this.output += String.fromCharCode((this.c - 97 + this.key) % 26 + 97);  // Lowercase
else   this.output += input.charAt(i);    
}
return answer.innerHTML= output;
 } 


This is better:

function Caesar(order){
    this.order = order;
    this.encode = encode;
    function encode(input){
        this.output = '';
        for (var i = 0; i &lt; input.length; i++) {
            var this.c = input.charCodeAt(i);
            if (this.c &gt;= 65 &amp;&amp; this.c &lt;=  90) 
                // Uppercase
                this.output += String.fromCharCode((this.c - 65 + this.order) % 26 + 65);  
            else if (this.c &gt;= 97 &amp;&amp; this.c &lt;= 122) 
                // Lowercase
                this.output += String.fromCharCode((this.c - 97 + this.key) % 26 + 97);  
            else   
                this.output += input.charAt(i);    
        }
    return answer.innerHTML= output;
} 

Caesar is an unfortunate name

It does not really say what it does ( one can guess )
it should not start with a capital C, it is not a constructor

The Caesar is completely wrong

it puts encode in this.encode and then never uses this.encode
if encode were called, it set this.output but then in the end you put output in answer.innerHTML
you try to access answer, but you never declared it with var, much less pointed it to the answer element with getElementById

You hardcode magical numbers

Some developers know 65 is A, you should put a comment about that
Same for 97 , 26 and 122

order -> what does order do ? Should be commented, it is not obvious
onclick ="encode()" &lt;- This is very old skool ( bad ), the correct way is using an addEventListener for load and in there use an addEventListener for click