0

Hi! I'm new to javascript. Just trying to write some code that combines stuff.
This is the javascript.

x=z;
y=new Date();
function test()
{
if (y<3)
{
	z=3;
}
else if (y>3 && y<7)
{
	z=7;
}
else if (y>7 && y<10)
{
	z=10;
}
}
function test2()
{
if(x<4)
	{
		document.write("3");
	}
else if(x<8)
	{
		document.write("7");
	}
else if(x<11)
	{
		document.write("10");
	}
}

and this is the html:

<html>
	<head>
		<script src="jslearn.js"></script>
	</head>
	<body onload="test()">
		<input type="Button" value="Button1" onclick="test2()"/>
</body>
</html>

I put the first part of the js in onload to see if that would help, but it didnt. The ideal would ofcourse for it all to happen once the button is pressed!

Thanks!

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by urtrivedi
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.