Saturday, 26 January 2013

Auto Code Generator Using Javascript API





Hello Friends , Many people looking for Auto Code Generator so I'm writing here " How to Create Auto Code Generator Using Javascript ".
I'm always use javascript generator in my blog for giving blogger widgets, and it's really nice method, and many of my readers ask me how to create javascript auto code generator, so in this post i'll give you some example codes for it, if your question is how to create javascript generator then i'm sure you are true beginners, Javascript language is hard for understand but not impossible to read/understand, you need to just study the code carefully, so let's start learn the coding..... :)

HTML CODE : 

Width: <input id="width" type="text" /> <br/><br/>
Height: <input id="height" type="text" /> <br/><br/>
Content: <input id="content" type="text" /><br/><br/>
<button id="go">Go</button><br/><br/>
<textarea id="code" cols="30" rows="10" ></textarea>

JAVASCRIPT CODE :


document.getElementById("go").onclick = function() {
    document.getElementById("code").innerHTML = "<div style='width:" + document.getElementById("width").value+ "; height:" + document.getElementById("height").value + ";'>" + document.getElementById("content").value + "</div>";
};



Let's trying to create a simple form where people input in some values and on submit auto generates the code below the form. Which then they can copy to use.


End.

1 comment: