/    Sign up×
Community /Pin to ProfileBookmark

Page only using javascript

hi all,

Can ny1 help me how to make a html page only using javasript. It shoud contain a text area, text fld and som basic things.. all should be declard in js.

i saw some code like this(givn below) . Can ny1 make some simple 1. using this concept. I need only javasript call in the body section.. all elements should be added to html from the js functions.

Pls help me.

lHTML+= “<div class=’loginscreen’>”;
lHTML+= “<BR>”;
lHTML+= “<table border=’0′ cellspacing=’0′ cellpadding=’0′ align=’right’><tr><td valign=’top’ UNSELECTABLE=’on’ ><span id=’lblLoginStatus’>&nbsp;</span></td></tr></table>”;
lHTML+= “<BR>”;
lHTML+= “<table border=’0′ cellspacing=’0′ cellpadding=’0′ class=’loginTable’ align=’center’ width=’98%’>”;
lHTML+= “<tr><td valign=’top’ UNSELECTABLE=’on’ align=’left’ style=’height:70px’>&nbsp;</td></tr>”;
lHTML+= “<tr><td valign=’top’ UNSELECTABLE=’on’ align=’left’ class=’logintextlabel’>User ID : </td></tr>”;
lHTML+= “<tr><td valign=’top’ UNSELECTABLE=’on’><input type=’text’ name=’txtLoginId’ id=’txtLoginId’ value=” maxlength=’40’ class=’logintextfield text’ onkeypress=’submitLoginForm(event)’ onmouseover=’javascript:this.focus();’/></td></tr>”;
lHTML+= “<tr><td valign=’top’ UNSELECTABLE=’on’ align=’left’ class=’logintextlabel’>Password : </td></tr>”;

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Gozzy82Oct 11.2011 — you can do it using document.write

<i>
</i>&lt;html&gt;
&lt;head&gt;&lt;title&gt;only js&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;

var theHTML = 'a textarea: &lt;textarea&gt;&lt;/textarea&gt;&lt;br /&gt;an input field:&lt;input type="text" /&gt;';
document.write(theHTML);

&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;


or you can create your in js and add them through js

<i>
</i>&lt;html&gt;
&lt;head&gt;&lt;title&gt;only js&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;
// make a textarea
var textarea = document.createElement('textarea');
// make a iput type=text
var inp = document.createElement('input');
inp.setAttribute('type', 'text');

// make a reference to the body of this html page
var body = document.getElementsByTagName('body')[0];
body.appendChild(textarea);
body.appendChild(inp);
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;


or you can use .innerHTML

<i>
</i>&lt;html&gt;
&lt;head&gt;&lt;title&gt;only js&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;

var theHTML = 'a textarea: &lt;textarea&gt;&lt;/textarea&gt;&lt;br /&gt;an input field:&lt;input type="text" /&gt;';
// make a reference to the body of this html page
var body = document.getElementsByTagName('body')[0];
body.innerHTML = theHTML;
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @johnrock spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 1.24,
social: @webDeveloperHQ,
});

legal: ({
terms: of use,
privacy: policy
analytics: Fullres
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: @dert,
tipped: article
amount: 1000 SATS,

tipper: @viney352,
tipped: article
amount: 10 SATS,
)...