my first js function

For all coding issues - MODers and programmers, HTML and more.

Moderators: Jeff250, fliptw

Post Reply
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7736
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

my first js function

Post by Isaac »

weee! Using a tutorial and some transferable Python knowledge I wrote my first function. Fun!

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Isaac's site</title>
</head>
<script type="text/javascript">
var x = 0;
function myloop() {
	for ( var x = 0; x <= 100; x++) {
		document.write(x%11);
		if (x%11==10) {
			document.write("<p></p>");
		}
	}
}



</script>
<body>
<form><input type="button" onclick="myloop()" value="Mybutton"> </form>

</body>
</html>
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Re: my first js function

Post by fliptw »

so it writes the remainder of a number divided by eleven, and if said remainder is 10, it prints a closed paragraph.

use the DOM luke....
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7736
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

Re: my first js function

Post by Isaac »

I'll get there eventually. I'm taking my time. I'm also able to do all my coding and testing within eclipse, which I really like. I need to figure out how to emulate my apache server so I don't have to test that code directly on the server. Then I could start writing and testing applications that stream data between the browser and server, which is cool.
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Re: my first js function

Post by fliptw »

run a local copy of apache on your machine.
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7736
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

Re: my first js function

Post by Isaac »

It might come to that, but I'm a wimp. The eclipse might have an internal plugin that could work with it's "local server" it's been using to test my js & html stuff.

I have not yet googled anything on this, because I'm still becoming friends with Javascript. After I am, I'll start working on blending server-side CGI with browser-side Javascript. At least that's the current plan.

edit:

Again, I'm going to learn Javascript before I push to blending it with Python. But here's a diagram with what I have in mind:
Diagram1.png
Diagram1.png (17.87 KiB) Viewed 1802 times
Made with Dia, the open source diagram application.
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6530
Joined: Sun Sep 05, 1999 2:01 am
Location: ❄️❄️❄️

Re: my first js function

Post by Jeff250 »

Yeah, document.write() is icky. Remember, jQuery is your friend.

There are at least two ways in which server-side python and client-side Javascript can interact. One is that python can write Javascript in a metaprogramming sense. Another is that Javascript can query server-side python via AJAX.
Post Reply