Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21280 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2013-09-12 03:40 -0700 |
| Last post | 2013-09-12 18:57 +0300 |
| Articles | 9 — 2 participants |
Back to article view | Back to comp.lang.javascript
Multiple forms in one HTML page. jonas.thornvall@gmail.com - 2013-09-12 03:40 -0700
Re: Multiple forms in one HTML page. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-09-12 14:17 +0300
Re: Multiple forms in one HTML page. jonas.thornvall@gmail.com - 2013-09-12 04:33 -0700
Re: Multiple forms in one HTML page. jonas.thornvall@gmail.com - 2013-09-12 04:37 -0700
Re: Multiple forms in one HTML page. jonas.thornvall@gmail.com - 2013-09-12 04:58 -0700
Re: Multiple forms in one HTML page. jonas.thornvall@gmail.com - 2013-09-12 06:10 -0700
Re: Multiple forms in one HTML page. jonas.thornvall@gmail.com - 2013-09-12 06:13 -0700
Re: Multiple forms in one HTML page. jonas.thornvall@gmail.com - 2013-09-12 07:57 -0700
Re: Multiple forms in one HTML page. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-09-12 18:57 +0300
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-09-12 03:40 -0700 |
| Subject | Multiple forms in one HTML page. |
| Message-ID | <c1c93558-3a49-4429-a263-2720ddd8ee01@googlegroups.com> |
In a framset with main,menu and canvas. I try to call different functions in canvas dependent upon which form i submit. Problem is that it seems that all forms are submitted, thus all the functions is called. Basicly i try to use buttons, to step forward, backward zoomin and zoomout. Why is it not possible, do i need to use divide or something else? <HTML> <script type="text/javascript"> </script> <body onload=parent.ulam.initdraw();> <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;"> <input type=submit value="Next"><P> </FORM> <FORM NAME=Bdoit onSubmit="parent.ulam.prev(); return false;"> <input type=submit value="Prev"><P> </FORM> <FORM NAME=Cdoit onSubmit="parent.ulam.zoomin(); return false;"> <input type=submit name="larger" value="Zoom+"><P> </FORM> <FORM NAME=Ddoit onSubmit="parent.ulam.zoomout(); return false;"> <input type=submit name="smaller" value="Zoom-"><P> </FORM> </body> </html>
[toc] | [next] | [standalone]
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Date | 2013-09-12 14:17 +0300 |
| Message-ID | <l0s7rg$su0$1@dont-email.me> |
| In reply to | #21280 |
2013-09-12 13:40, jonas.thornvall@gmail.com wrote: > Problem is that it seems that all forms are submitted, thus all the > functions is called. Then there's something you haven't described at all. As such, each form works independently of other forms. So it seems that it's your JavaScript code that causes the issue, and that code has not been disclosed. > Basicly i try to use buttons, to step forward, backward zoomin and zoomout. If the logic relies on JavaScript (i.e., the page or application does not work at all without it), what do you need forms for? Your forms seem to contain just one submit button each. You could use just JavaScript-powered buttons, no <form> element. If you wish to code robustly, with server-side fallback for situations where JavaScript is disabled, then it makes sense to wrap the buttons in forms. But the forms need action=... attributes to make this useful in any way. > <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;"> What are ulam and its methods, and what do they do? -- Yucca, http://www.cs.tut.fi/~jkorpela/
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-09-12 04:33 -0700 |
| Message-ID | <9cffe031-dc2c-46e7-b2fe-a0f275c79b7b@googlegroups.com> |
| In reply to | #21281 |
Den torsdagen den 12:e september 2013 kl. 13:17:06 UTC+2 skrev Jukka K. Korpela:
> 2013-09-12 13:40, jonas.thornvall@gmail.com wrote:
>
>
>
> > Problem is that it seems that all forms are submitted, thus all the
>
> > functions is called.
>
>
>
> Then there's something you haven't described at all. As such, each form
>
> works independently of other forms. So it seems that it's your
>
> JavaScript code that causes the issue, and that code has not been disclosed.
>
>
>
> > Basicly i try to use buttons, to step forward, backward zoomin and zoomout.
>
>
>
> If the logic relies on JavaScript (i.e., the page or application does
>
> not work at all without it), what do you need forms for? Your forms seem
>
> to contain just one submit button each. You could use just
>
> JavaScript-powered buttons, no <form> element.
>
>
>
> If you wish to code robustly, with server-side fallback for situations
>
> where JavaScript is disabled, then it makes sense to wrap the buttons in
>
> forms. But the forms need action=... attributes to make this useful in
>
> any way.
>
>
>
> > <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;">
>
>
>
> What are ulam and its methods, and what do they do?
>
>
>
> --
>
> Yucca, http://www.cs.tut.fi/~jkorpela/
Hello Jukka, it actually seem like it does not matter which button i press all the functions will be called. So basicly the last value is set. A solution nested frameset with forms in separate HTML pages not that nice.
It is just recreational so here is the code.
*****Main Frameset
<!DOCTYPE html>
<HTML>
<frameset cols="6%,94%">
<frame src="menu.html" name="menu">
<frame src="canvas.html" name="ulam">
</frameset>
</HTML>
*****Menu
<HTML>
<body onload=parent.ulam.initdraw();>
<FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;">
<input type=submit value="Next"><P>
</FORM>
<FORM NAME=Bdoit onSubmit="parent.ulam.prev(); return false;">
<input type=submit value="Prev"><P>
</FORM>
<FORM NAME=Cdoit onSubmit="parent.ulam.zoomin(); return false;">
<input type=submit name="larger" value="Zoom+"><P>
</FORM>
<FORM NAME=Ddoit onSubmit="parent.ulam.zoomout(); return false;">
<input type=submit name="smaller" value="Zoom-"><P>
</FORM>
</body>
</html>
******Canvas
<!DOCTYPE html>
<html>
<head></head>
<canvas id="myCanvas" width="2100" height="2100">Your browser does not support the HTML5 canvas tag.</canvas>
<script type="text/javascript">
var divisorGlobal = 2;
var numberGlobal = 1;
var MAX = 69696;
var array = [];
var start = 1;
var size=1;
function isPrime()
{
n = MAX;
// Eratosthenes algorithm to find all primes under n
upperLimit = Math.sqrt(n);
// Make an array from 2 to (n - 1)
array[0] = false;
array[1] = false;
for (var i = 0; i < n; i ++ )
{
array.push(true);
}
// Remove multiples of primes starting from 2, 3, 5, ...
i = 2;
while (i <= upperLimit)
{
if (array[i])
{
for (var j = i * i; j < n; j += i)
{
array[j] = false;
}
}
i ++ ;
}
return array;
}
function clear()
{
ctx.clearRect(0, 0, 2150, 2150);
}
function anime()
{
divisorGlobal=divisorGlobal+size;
numberGlobal=numberGlobal+start;
divisor = divisorGlobal;
number = numberGlobal;
asize = 67 / divisor;
storlek = 54;
fstor = 15 / divisor;
afonten = "bold " + fstor + "px Arial";
height = storlek / divisor;
width = storlek / divisor;
v_inner = 0;
h_inner = 0;
h_outer = 0;
v_outer = 0;
down = 1;
back = 2;
ctx.font = afonten;
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_outer, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
h_inner = h_inner + 15;
h_outer = h_outer + asize;
number ++ ;
while(number < MAX)
{
vertical = 0;
v_outer = 0;
v_inner = v_outer;
h_inner = h_outer;
while(vertical < down)
{
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_inner, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 1, v_inner + 12);
v_inner = v_inner + asize;
vertical ++ ;
number ++ ;
}
down ++ ;
q = 0;
h_inner = h_outer;
while(q < back)
{
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_inner, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
h_inner = h_inner - asize;
q ++ ;
number ++ ;
}
back ++ ;
h_outer = h_outer + asize;
}
number ++ ;
}
function draw()
{
clear();
anime();
}
next()
{
start++;
draw();
}
prev()
{
start--;
draw();
}
zoomin()
{
size++;
draw();
}
zoomout()
{
size--;
draw();
}
function initdraw()
{
isPrime();
canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
draw();
}
function initanime()
{
isPrime();
canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
return setInterval(draw, 0);
}
</script>
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-09-12 04:37 -0700 |
| Message-ID | <992d4ee6-80ff-4afb-9db7-4dbb3a7e399f@googlegroups.com> |
| In reply to | #21281 |
Den torsdagen den 12:e september 2013 kl. 13:17:06 UTC+2 skrev Jukka K. Korpela: > 2013-09-12 13:40, jonas.thornvall@gmail.com wrote: > > > > > Problem is that it seems that all forms are submitted, thus all the > > > functions is called. > > > > Then there's something you haven't described at all. As such, each form > > works independently of other forms. So it seems that it's your > > JavaScript code that causes the issue, and that code has not been disclosed. > > > > > Basicly i try to use buttons, to step forward, backward zoomin and zoomout. > > > > If the logic relies on JavaScript (i.e., the page or application does > > not work at all without it), what do you need forms for? Your forms seem > > to contain just one submit button each. You could use just > > JavaScript-powered buttons, no <form> element. > > > > If you wish to code robustly, with server-side fallback for situations > > where JavaScript is disabled, then it makes sense to wrap the buttons in > > forms. But the forms need action=... attributes to make this useful in > > any way. > > > > > <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;"> > > > > What are ulam and its methods, and what do they do? > > > > -- > > Yucca, http://www.cs.tut.fi/~jkorpela/ Sorry i am tired missed to write function...
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-09-12 04:58 -0700 |
| Message-ID | <50b441f0-cea6-4831-9c5d-76c07ed78415@googlegroups.com> |
| In reply to | #21283 |
Den torsdagen den 12:e september 2013 kl. 13:37:11 UTC+2 skrev jonas.t...@gmail.com:
> Den torsdagen den 12:e september 2013 kl. 13:17:06 UTC+2 skrev Jukka K. Korpela:
>
> > 2013-09-12 13:40, jonas.thornvall@gmail.com wrote:
>
> >
>
> >
>
> >
>
> > > Problem is that it seems that all forms are submitted, thus all the
>
> >
>
> > > functions is called.
>
> >
>
> >
>
> >
>
> > Then there's something you haven't described at all. As such, each form
>
> >
>
> > works independently of other forms. So it seems that it's your
>
> >
>
> > JavaScript code that causes the issue, and that code has not been disclosed.
>
> >
>
> >
>
> >
>
> > > Basicly i try to use buttons, to step forward, backward zoomin and zoomout.
>
> >
>
> >
>
> >
>
> > If the logic relies on JavaScript (i.e., the page or application does
>
> >
>
> > not work at all without it), what do you need forms for? Your forms seem
>
> >
>
> > to contain just one submit button each. You could use just
>
> >
>
> > JavaScript-powered buttons, no <form> element.
>
> >
>
> >
>
> >
>
> > If you wish to code robustly, with server-side fallback for situations
>
> >
>
> > where JavaScript is disabled, then it makes sense to wrap the buttons in
>
> >
>
> > forms. But the forms need action=... attributes to make this useful in
>
> >
>
> > any way.
>
> >
>
> >
>
> >
>
> > > <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;">
>
> >
>
> >
>
> >
>
> > What are ulam and its methods, and what do they do?
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > Yucca, http://www.cs.tut.fi/~jkorpela/
>
>
>
> Sorry i am tired missed to write function...
<!DOCTYPE html>
<html>
<head></head>
<canvas id="myCanvas" width="2100" height="2100">Your browser does not support the HTML5 canvas tag.</canvas>
<script type="text/javascript">
var divisorGlobal = 2;
var numberGlobal = 1;
var MAX = 69696;
var array = [];
var start = 0;
var size=0;
function isPrime()
{
n = MAX;
// Eratosthenes algorithm to find all primes under n
upperLimit = Math.sqrt(n);
// Make an array from 2 to (n - 1)
array[0] = false;
array[1] = false;
for (var i = 0; i < n; i ++ )
{
array.push(true);
}
// Remove multiples of primes starting from 2, 3, 5, ...
i = 2;
while (i <= upperLimit)
{
if (array[i])
{
for (var j = i * i; j < n; j += i)
{
array[j] = false;
}
}
i ++ ;
}
return array;
}
function clear()
{
ctx.clearRect(0, 0, 2150, 2150);
}
function anime()
{
divisorGlobal=divisorGlobal+size;
numberGlobal=numberGlobal+start;
divisor = divisorGlobal;
number = numberGlobal;
asize = 67 / divisor;
storlek = 54;
fstor = 15 / divisor;
afonten = "bold " + fstor + "px Arial";
height = storlek / divisor;
width = storlek / divisor;
v_inner = 0;
h_inner = 0;
h_outer = 0;
v_outer = 0;
down = 1;
back = 2;
ctx.font = afonten;
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_outer, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
h_inner = h_inner + 15;
h_outer = h_outer + asize;
number ++ ;
while(number < MAX)
{
vertical = 0;
v_outer = 0;
v_inner = v_outer;
h_inner = h_outer;
while(vertical < down)
{
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_inner, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 1, v_inner + 12);
v_inner = v_inner + asize;
vertical ++ ;
number ++ ;
}
down ++ ;
q = 0;
h_inner = h_outer;
while(q < back)
{
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_inner, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
h_inner = h_inner - asize;
q ++ ;
number ++ ;
}
back ++ ;
h_outer = h_outer + asize;
}
number ++ ;
}
function draw()
{
clear();
anime();
}
function next()
{
start=0;
start++;
draw();
}
function prev()
{
start=0;
start--;
draw();
}
function zoomin()
{
size=0;
size--;
draw();
}
function zoomout()
{
size=0;
size++;
draw();
}
function initdraw()
{
isPrime();
canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
draw();
}
function initanime()
{
isPrime();
canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
return setInterval(draw, 0);
}
</script>
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-09-12 06:10 -0700 |
| Message-ID | <3cd3226c-d9ac-4779-af02-ec4d3e2aa26a@googlegroups.com> |
| In reply to | #21284 |
Den torsdagen den 12:e september 2013 kl. 13:58:42 UTC+2 skrev jonas.t...@gmail.com:
> Den torsdagen den 12:e september 2013 kl. 13:37:11 UTC+2 skrev jonas.t...@gmail.com:
>
> > Den torsdagen den 12:e september 2013 kl. 13:17:06 UTC+2 skrev Jukka K. Korpela:
>
> >
>
> > > 2013-09-12 13:40, jonas.thornvall@gmail.com wrote:
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > Problem is that it seems that all forms are submitted, thus all the
>
> >
>
> > >
>
> >
>
> > > > functions is called.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Then there's something you haven't described at all. As such, each form
>
> >
>
> > >
>
> >
>
> > > works independently of other forms. So it seems that it's your
>
> >
>
> > >
>
> >
>
> > > JavaScript code that causes the issue, and that code has not been disclosed.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > Basicly i try to use buttons, to step forward, backward zoomin and zoomout.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > If the logic relies on JavaScript (i.e., the page or application does
>
> >
>
> > >
>
> >
>
> > > not work at all without it), what do you need forms for? Your forms seem
>
> >
>
> > >
>
> >
>
> > > to contain just one submit button each. You could use just
>
> >
>
> > >
>
> >
>
> > > JavaScript-powered buttons, no <form> element.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > If you wish to code robustly, with server-side fallback for situations
>
> >
>
> > >
>
> >
>
> > > where JavaScript is disabled, then it makes sense to wrap the buttons in
>
> >
>
> > >
>
> >
>
> > > forms. But the forms need action=... attributes to make this useful in
>
> >
>
> > >
>
> >
>
> > > any way.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;">
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > What are ulam and its methods, and what do they do?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > --
>
> >
>
> > >
>
> >
>
> > > Yucca, http://www.cs.tut.fi/~jkorpela/
>
> >
>
> >
>
> >
>
> > Sorry i am tired missed to write function...
>
>
>
> <!DOCTYPE html>
>
> <html>
>
> <head></head>
>
> <canvas id="myCanvas" width="2100" height="2100">Your browser does not support the HTML5 canvas tag.</canvas>
>
>
>
> <script type="text/javascript">
>
> var divisorGlobal = 2;
>
> var numberGlobal = 1;
>
> var MAX = 69696;
>
> var array = [];
>
> var start = 0;
>
> var size=0;
>
> function isPrime()
>
> {
>
> n = MAX;
>
> // Eratosthenes algorithm to find all primes under n
>
> upperLimit = Math.sqrt(n);
>
>
>
> // Make an array from 2 to (n - 1)
>
> array[0] = false;
>
> array[1] = false;
>
> for (var i = 0; i < n; i ++ )
>
> {
>
> array.push(true);
>
> }
>
>
>
> // Remove multiples of primes starting from 2, 3, 5, ...
>
> i = 2;
>
> while (i <= upperLimit)
>
> {
>
> if (array[i])
>
> {
>
> for (var j = i * i; j < n; j += i)
>
> {
>
> array[j] = false;
>
>
>
> }
>
> }
>
> i ++ ;
>
> }
>
> return array;
>
> }
>
>
>
>
>
> function clear()
>
> {
>
> ctx.clearRect(0, 0, 2150, 2150);
>
> }
>
>
>
> function anime()
>
> {
>
> divisorGlobal=divisorGlobal+size;
>
> numberGlobal=numberGlobal+start;
>
> divisor = divisorGlobal;
>
> number = numberGlobal;
>
> asize = 67 / divisor;
>
> storlek = 54;
>
> fstor = 15 / divisor;
>
> afonten = "bold " + fstor + "px Arial";
>
> height = storlek / divisor;
>
> width = storlek / divisor;
>
> v_inner = 0;
>
> h_inner = 0;
>
> h_outer = 0;
>
> v_outer = 0;
>
> down = 1;
>
> back = 2;
>
> ctx.font = afonten;
>
> ctx.fillStyle = 'yellow';
>
> if(array[number])
>
> {
>
> ctx.fillStyle = 'blue';
>
> }
>
> ctx.fillRect(h_inner, v_outer, width, height);
>
> ctx.fillStyle = "black";
>
> if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
>
> h_inner = h_inner + 15;
>
> h_outer = h_outer + asize;
>
> number ++ ;
>
>
>
> while(number < MAX)
>
> {
>
> vertical = 0;
>
> v_outer = 0;
>
> v_inner = v_outer;
>
> h_inner = h_outer;
>
> while(vertical < down)
>
> {
>
> ctx.fillStyle = 'yellow';
>
> if(array[number])
>
> {
>
> ctx.fillStyle = 'blue';
>
> }
>
> ctx.fillRect(h_inner, v_inner, width, height);
>
> ctx.fillStyle = "black";
>
> if (divisor < 3)ctx.fillText(number, h_inner + 1, v_inner + 12);
>
> v_inner = v_inner + asize;
>
> vertical ++ ;
>
> number ++ ;
>
> }
>
>
>
> down ++ ;
>
> q = 0;
>
> h_inner = h_outer;
>
>
>
> while(q < back)
>
> {
>
> ctx.fillStyle = 'yellow';
>
> if(array[number])
>
> {
>
> ctx.fillStyle = 'blue';
>
> }
>
> ctx.fillRect(h_inner, v_inner, width, height);
>
> ctx.fillStyle = "black";
>
> if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
>
> h_inner = h_inner - asize;
>
> q ++ ;
>
> number ++ ;
>
> }
>
>
>
> back ++ ;
>
> h_outer = h_outer + asize;
>
>
>
> }
>
> number ++ ;
>
> }
>
>
>
> function draw()
>
> {
>
>
>
> clear();
>
> anime();
>
>
>
> }
>
>
>
>
>
> function next()
>
> {
>
> start=0;
>
> start++;
>
> draw();
>
>
>
>
>
> }
>
>
>
>
>
> function prev()
>
> {
>
> start=0;
>
> start--;
>
> draw();
>
> }
>
>
>
>
>
> function zoomin()
>
> {
>
> size=0;
>
> size--;
>
> draw();
>
> }
>
>
>
> function zoomout()
>
> {
>
> size=0;
>
> size++;
>
> draw();
>
> }
>
>
>
> function initdraw()
>
> {
>
> isPrime();
>
> canvas = document.getElementById("myCanvas");
>
> ctx = canvas.getContext("2d");
>
> draw();
>
> }
>
>
>
> function initanime()
>
> {
>
> isPrime();
>
> canvas = document.getElementById("myCanvas");
>
> ctx = canvas.getContext("2d");
>
> return setInterval(draw, 0);
>
> }
>
>
>
>
>
>
>
>
>
> </script>
Nowhere working as it should but fun to play with zoom in and out and negative squares.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-09-12 06:13 -0700 |
| Message-ID | <eb1a7c63-a283-43e1-b52b-a5f7eb35bb21@googlegroups.com> |
| In reply to | #21284 |
Den torsdagen den 12:e september 2013 kl. 13:58:42 UTC+2 skrev jonas.t...@gmail.com:
> Den torsdagen den 12:e september 2013 kl. 13:37:11 UTC+2 skrev jonas.t...@gmail.com:
>
> > Den torsdagen den 12:e september 2013 kl. 13:17:06 UTC+2 skrev Jukka K. Korpela:
>
> >
>
> > > 2013-09-12 13:40, jonas.thornvall@gmail.com wrote:
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > Problem is that it seems that all forms are submitted, thus all the
>
> >
>
> > >
>
> >
>
> > > > functions is called.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Then there's something you haven't described at all. As such, each form
>
> >
>
> > >
>
> >
>
> > > works independently of other forms. So it seems that it's your
>
> >
>
> > >
>
> >
>
> > > JavaScript code that causes the issue, and that code has not been disclosed.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > Basicly i try to use buttons, to step forward, backward zoomin and zoomout.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > If the logic relies on JavaScript (i.e., the page or application does
>
> >
>
> > >
>
> >
>
> > > not work at all without it), what do you need forms for? Your forms seem
>
> >
>
> > >
>
> >
>
> > > to contain just one submit button each. You could use just
>
> >
>
> > >
>
> >
>
> > > JavaScript-powered buttons, no <form> element.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > If you wish to code robustly, with server-side fallback for situations
>
> >
>
> > >
>
> >
>
> > > where JavaScript is disabled, then it makes sense to wrap the buttons in
>
> >
>
> > >
>
> >
>
> > > forms. But the forms need action=... attributes to make this useful in
>
> >
>
> > >
>
> >
>
> > > any way.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > > <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;">
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > What are ulam and its methods, and what do they do?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > --
>
> >
>
> > >
>
> >
>
> > > Yucca, http://www.cs.tut.fi/~jkorpela/
>
> >
>
> >
>
> >
>
> > Sorry i am tired missed to write function...
>
>
>
> <!DOCTYPE html>
>
> <html>
>
> <head></head>
>
> <canvas id="myCanvas" width="2100" height="2100">Your browser does not support the HTML5 canvas tag.</canvas>
>
>
>
> <script type="text/javascript">
>
> var divisorGlobal = 2;
>
> var numberGlobal = 1;
>
> var MAX = 69696;
>
> var array = [];
>
> var start = 0;
>
> var size=0;
>
> function isPrime()
>
> {
>
> n = MAX;
>
> // Eratosthenes algorithm to find all primes under n
>
> upperLimit = Math.sqrt(n);
>
>
>
> // Make an array from 2 to (n - 1)
>
> array[0] = false;
>
> array[1] = false;
>
> for (var i = 0; i < n; i ++ )
>
> {
>
> array.push(true);
>
> }
>
>
>
> // Remove multiples of primes starting from 2, 3, 5, ...
>
> i = 2;
>
> while (i <= upperLimit)
>
> {
>
> if (array[i])
>
> {
>
> for (var j = i * i; j < n; j += i)
>
> {
>
> array[j] = false;
>
>
>
> }
>
> }
>
> i ++ ;
>
> }
>
> return array;
>
> }
>
>
>
>
>
> function clear()
>
> {
>
> ctx.clearRect(0, 0, 2150, 2150);
>
> }
>
>
>
> function anime()
>
> {
>
> divisorGlobal=divisorGlobal+size;
>
> numberGlobal=numberGlobal+start;
>
> divisor = divisorGlobal;
>
> number = numberGlobal;
>
> asize = 67 / divisor;
>
> storlek = 54;
>
> fstor = 15 / divisor;
>
> afonten = "bold " + fstor + "px Arial";
>
> height = storlek / divisor;
>
> width = storlek / divisor;
>
> v_inner = 0;
>
> h_inner = 0;
>
> h_outer = 0;
>
> v_outer = 0;
>
> down = 1;
>
> back = 2;
>
> ctx.font = afonten;
>
> ctx.fillStyle = 'yellow';
>
> if(array[number])
>
> {
>
> ctx.fillStyle = 'blue';
>
> }
>
> ctx.fillRect(h_inner, v_outer, width, height);
>
> ctx.fillStyle = "black";
>
> if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
>
> h_inner = h_inner + 15;
>
> h_outer = h_outer + asize;
>
> number ++ ;
>
>
>
> while(number < MAX)
>
> {
>
> vertical = 0;
>
> v_outer = 0;
>
> v_inner = v_outer;
>
> h_inner = h_outer;
>
> while(vertical < down)
>
> {
>
> ctx.fillStyle = 'yellow';
>
> if(array[number])
>
> {
>
> ctx.fillStyle = 'blue';
>
> }
>
> ctx.fillRect(h_inner, v_inner, width, height);
>
> ctx.fillStyle = "black";
>
> if (divisor < 3)ctx.fillText(number, h_inner + 1, v_inner + 12);
>
> v_inner = v_inner + asize;
>
> vertical ++ ;
>
> number ++ ;
>
> }
>
>
>
> down ++ ;
>
> q = 0;
>
> h_inner = h_outer;
>
>
>
> while(q < back)
>
> {
>
> ctx.fillStyle = 'yellow';
>
> if(array[number])
>
> {
>
> ctx.fillStyle = 'blue';
>
> }
>
> ctx.fillRect(h_inner, v_inner, width, height);
>
> ctx.fillStyle = "black";
>
> if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
>
> h_inner = h_inner - asize;
>
> q ++ ;
>
> number ++ ;
>
> }
>
>
>
> back ++ ;
>
> h_outer = h_outer + asize;
>
>
>
> }
>
> number ++ ;
>
> }
>
>
>
> function draw()
>
> {
>
>
>
> clear();
>
> anime();
>
>
>
> }
>
>
>
>
>
> function next()
>
> {
>
> start=0;
>
> start++;
>
> draw();
>
>
>
>
>
> }
>
>
>
>
>
> function prev()
>
> {
>
> start=0;
>
> start--;
>
> draw();
>
> }
>
>
>
>
>
> function zoomin()
>
> {
>
> size=0;
>
> size--;
>
> draw();
>
> }
>
>
>
> function zoomout()
>
> {
>
> size=0;
>
> size++;
>
> draw();
>
> }
>
>
>
> function initdraw()
>
> {
>
> isPrime();
>
> canvas = document.getElementById("myCanvas");
>
> ctx = canvas.getContext("2d");
>
> draw();
>
> }
>
>
>
> function initanime()
>
> {
>
> isPrime();
>
> canvas = document.getElementById("myCanvas");
>
> ctx = canvas.getContext("2d");
>
> return setInterval(draw, 0);
>
> }
>
>
>
>
>
>
>
>
>
> </script>
Not working way intended but fun to play with zoom in out positive and negative squares with prime configuration.
<!DOCTYPE html>
<html>
<head></head>
<canvas id="myCanvas" width="2100" height="2100">Your browser does not support the HTML5 canvas tag.</canvas>
<script type="text/javascript">
var divisorGlobal = 15;
var numberGlobal = 1;
var MAX = 69696;
var array = [];
var start = 0;
var size=0;
var run=0;
multip=1;
function isPrime()
{
n = MAX;
// Eratosthenes algorithm to find all primes under n
upperLimit = Math.sqrt(n);
// Make an array from 2 to (n - 1)
array[0] = false;
array[1] = false;
for (var i = 0; i < n; i ++ )
{
array.push(true);
}
// Remove multiples of primes starting from 2, 3, 5, ...
i = 2;
while (i <= upperLimit)
{
if (array[i])
{
for (var j = i * i; j < n; j += i)
{
array[j] = false;
}
}
i ++ ;
}
return array;
}
function clear()
{
ctx.clearRect(0, 0, 2150, 2150);
}
function anime()
{
divisorGlobal=divisorGlobal+size;
numberGlobal=numberGlobal+start;
if(run=1)numberGlobal=numberGlobal+multip;
divisor = divisorGlobal;
number = numberGlobal;
asize = 67 / divisor;
storlek = 54;
fstor = 15 / divisor;
afonten = "bold " + fstor + "px Arial";
height = storlek / divisor;
width = storlek / divisor;
v_inner = 0;
h_inner = 0;
h_outer = 0;
v_outer = 0;
down = 1;
back = 2;
ctx.font = afonten;
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_outer, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
h_inner = h_inner + 15;
h_outer = h_outer + asize;
number ++ ;
while(number < MAX)
{
vertical = 0;
v_outer = 0;
v_inner = v_outer;
h_inner = h_outer;
while(vertical < down)
{
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_inner, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 1, v_inner + 12);
v_inner = v_inner + asize;
vertical ++ ;
number ++ ;
}
down ++ ;
q = 0;
h_inner = h_outer;
while(q < back)
{
ctx.fillStyle = 'yellow';
if(array[number])
{
ctx.fillStyle = 'blue';
}
ctx.fillRect(h_inner, v_inner, width, height);
ctx.fillStyle = "black";
if (divisor < 3)ctx.fillText(number, h_inner + 3, v_inner + 12);
h_inner = h_inner - asize;
q ++ ;
number ++ ;
}
back ++ ;
h_outer = h_outer + asize;
}
number ++ ;
}
function draw()
{
clear();
anime();
}
function next()
{
multip=+1;
start=0;
start++;
draw();
}
function prev()
{
multip=-1;
start=0;
start--;
draw();
}
function zoomin()
{
size=0;
size=size-1;
draw();
}
function zoomout()
{
size=0;
size=size+1;
draw();
}
function initdraw()
{
isPrime();
canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
draw();
}
function initanime()
{
run=1;
return setInterval(draw, 0);
}
</script>
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-09-12 07:57 -0700 |
| Message-ID | <09025388-c3ee-42be-9c64-52481ac01ca8@googlegroups.com> |
| In reply to | #21281 |
Den torsdagen den 12:e september 2013 kl. 13:17:06 UTC+2 skrev Jukka K. Korpela: > 2013-09-12 13:40, jonas.thornvall@gmail.com wrote: > > > > > Problem is that it seems that all forms are submitted, thus all the > > > functions is called. > > > > Then there's something you haven't described at all. As such, each form > > works independently of other forms. So it seems that it's your > > JavaScript code that causes the issue, and that code has not been disclosed. > > > > > Basicly i try to use buttons, to step forward, backward zoomin and zoomout. > > > > If the logic relies on JavaScript (i.e., the page or application does > > not work at all without it), what do you need forms for? Your forms seem > > to contain just one submit button each. You could use just > > JavaScript-powered buttons, no <form> element. > > > > If you wish to code robustly, with server-side fallback for situations > > where JavaScript is disabled, then it makes sense to wrap the buttons in > > forms. But the forms need action=... attributes to make this useful in > > any way. > > > > > <FORM NAME=Adoit onSubmit="parent.ulam.next(); return false;"> > > > > What are ulam and its methods, and what do they do? > > > > -- > > Yucca, http://www.cs.tut.fi/~jkorpela/ I fixed it. http://web.comhem.se/jonasth/main.html
[toc] | [prev] | [next] | [standalone]
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Date | 2013-09-12 18:57 +0300 |
| Message-ID | <l0so8o$n64$1@dont-email.me> |
| In reply to | #21295 |
2013-09-12 17:57, jonas.thornvall@gmail.com wrote: [A comprehensive quote, followed by:] > I fixed it. Nobody really cares, after your lengthy postings that did not even try to explain the problem you had, or what you regard as the solution. The odds are that your "fix" is yet another problem, which hasn't exploded yet. But I'm afraid we couldn't care less. -- Yucca, http://www.cs.tut.fi/~jkorpela/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web