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!

Date is little complex thing to begin with. You are intialising Y to date and comparing with integer.
So If you learning JS, then start with simple types. Use chrome, you may find javascript debugger in chrome tools.

Reference http://www.w3schools.com/js/default.asp

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.