/    Sign up×
Community /Pin to ProfileBookmark

Javascript and HTML Question

i was wondering if there a another way to write alot of HTML using javascript..
i know of using variables
ex.)

[CODE]
function makeTable(){
var txtBin = “html”
txtBin += “html”
document.getElementById(‘newTable’).innerHTML = txtBin;
}[/CODE]

but is there another way thats easier and more reliable?

o…and for you people who where gonna say…”why not just use HTML…its easier…”
with using javascript i can edit when the function takes place…plus i can put it on multiple pages easily by adding a “<div id=’newTable’></div>”

to post a comment
JavaScript

14 Comments(s)

Copy linkTweet thisAlerts:
@JPnycApr 09.2006 — What you have there isn't going to write a table. And you can't add it to other pages in the way you described either.
Copy linkTweet thisAlerts:
@BetaScriptinauthorApr 09.2006 — that was an example...i had posted a code on here that used that same method...but theres little room for error...

im just asking if theres another way to have javascript place the HTML on a page.

EDIT: the link to an example is [URL=http://www.webdeveloper.com/forum/showthread.php?t=102265]here[/URL]
Copy linkTweet thisAlerts:
@JPnycApr 09.2006 — Well you could use a loop for the actual rows and cells, assuming there's a lot of them. You can then vary the amount of em by varying the test.
Copy linkTweet thisAlerts:
@NotionCommotionApr 09.2006 — While not JavaScript, PHP would likely do very well for you.
Copy linkTweet thisAlerts:
@JPnycApr 09.2006 — PHP would be a better choice in that it can't be disabled. If a user comes to you with JS disabled, your page will be blank.
Copy linkTweet thisAlerts:
@BetaScriptinauthorApr 09.2006 — thanx for the good input=)

ill try my luck with PHP...but before i go...does anyone know a good PHP Tutorial? like a link to one with all the basics...or ,perhaps even better, a site?

thanx again for the input=)
Copy linkTweet thisAlerts:
@SaintJimmyApr 09.2006 — Check out the basic PHP tutorials at [URL=http://www.webmonkey.com]Webmonkey[/URL] . They're pretty easy to understand if you want to get just a basic overview of the language and it's features.
Copy linkTweet thisAlerts:
@BetaScriptinauthorApr 09.2006 — thanx guys
Copy linkTweet thisAlerts:
@NotionCommotionApr 09.2006 — If you are new on the subject, I would also highly recommend the "In EasySteps" books. They have one on PHP as well as various other topics,are $9.95 each, and will get you up and running in no time.
Copy linkTweet thisAlerts:
@BetaScriptinauthorApr 09.2006 — i was thinking about gettin books...but i didnt know where to get them....lol, i was gonna check Mediaplay...(a local bookc/media store)...and see if they had them
Copy linkTweet thisAlerts:
@JPnycApr 09.2006 — If you know any scripting language, then you just need to familiarize yourself with the particular methods of a new language. Check [url=http://us2.php.net/]this[/url] resource out for that purpose.
Copy linkTweet thisAlerts:
@wilfordbrimleyApr 09.2006 — [code=html]
<html>
<head><title>tables</title></head>
<body>
[code=php]
<?php
// this makes a table with arbitrary number or rows and columns
function makeTable($rows, $cols) {
echo ("<table>");
for ($i = 0; $i < $rows; $i++) {
echo ("<tr>");
for ($j = 0; $j < $cols; $j++) {
echo("<td></td>");
}
echo ("</tr>");
}
echo ("</table>");
}
?>
[/code]

<div id="thetable">
[code=php]<?php makeTable(64, 13); ?>[/code]
</div>

</body>

</html>
[code=html]
Copy linkTweet thisAlerts:
@NotionCommotionApr 10.2006 — There are literarily tons of books, but the problem from my prospective is each one weighs ton and the only reason I would ever get one of the big ones is as a reference, and the web is a good substitute for that. The reason I like the EasyStep books is I could read (and understand) it in several hours (around 100 pages) and have a basic understanding. Barnes and Noble has them and I have seen them to a lesser degree at other places. PS, I don't work for them!
×

Success!

Help @BetaScriptin 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 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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