Hello. I am new to javascripting. I am building a simple application. What I need is when the javascript function is called, I dont need the page to be reloaded and theoutput to be displayed in a new page. the output must be displayed write below input tag. When I tried the below I got a new page with no other styles and html except "Hello World". <input type="button" class="green" onclick="fuct()" value="Generate My Scrap" /> HTML: function funct() { document.write("Hello World"); } Code (markup):
You could do something like this ... <input type="button" class="green" onClick="myFunction()" value="Generate My Scrap" /> <div id="contentSwap" name="contentSwap"></div> Code (markup): function myFunction() { document.getElementById('contentSwap').innerHTML='Hello World'; } Code (markup):