A
Andy
I'm not sure why my checkbox code is not working as per intended. It
always keeps saying "Please select the department" even though I check
the department... appreciate any help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Welcome to the Scripting Store</TITLE>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
<SCRIPT>
// Banner Rotator logic
//Load banner elements into array
var banners = new
Array("banner1.jpg","banner2.jpg","banner3.jpg","banner4.jpg")
//Set banner counter to 0
var bnrCntr = 0
//Function that actually rotates the banner
function bancycle() {
bnrCntr = bnrCntr + 1
if (bnrCntr == 4) {
bnrCntr = 0
}
document.Banner.src = banners[bnrCntr]
setTimeout("bancycle()",3000)
}
//End Banner Rotator Logic
</SCRIPT>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY onload=bancycle()>
<TABLE borderColor=blue width=700 border=1>
<TBODY>
<TR>
<TD width="30%"><IMG name=Banner></TD>
<TD align=middle>
<H1>Welcome to the Scripting
Store</H1></TD></TR></TBODY></TABLE><BR>
<SCRIPT language=javascript>
document.writeln("Today is: ");
var nDate = new Date();
document.writeln(nDate);
var strName = new String();
strName = window.prompt("What is your Name?", "FirstNameOnly");
//document.write("Welcome " + strName + "<br>");
document.write("<h2>Hello " + strName + "</h2>");
var varStatus;
status = "Hello " + strName + " - Welcome to the Scripting Store";
//Year(Now());
</SCRIPT>
<P>Please select one of our departments listed below</P><BR><INPUT
onclick=locateDepartment() type=button value="Select Department"
name=btnSelect>
<BR>
<SCRIPT>
var varDept = new Array(3);
varDept[0] = "Books";
varDept[1] = "Computers";
varDept[2] = "Caffeine free products";
var numMax = varDept.length;
var strDept;
for (var i=0; i <numMax; ++i)
{
document.write("<p><input type='checkbox' value=" + + "name=" +
varDept + ">" + varDept + "</p>");
}
</SCRIPT>
<SCRIPT>
function locateDepartment()
{
var varselect = true;
var varMax = 3;
for (var x=0; x < varMax; ++x)
{
if (varDept[x].checked == true)
{
if ([x] == 0)
{
location.href='book.htm';
}
else if ([x] == 1)
{
location.href='Caffiene.htm';
}
else if ([x] == 2)
{
location.href='Computers.htm';
}
}
else
{
varselect = false;
}
}
if (varselect == false)
{
window.alert("Please Select a Department");
return false;
}
}
</SCRIPT>
</BODY></HTML>
always keeps saying "Please select the department" even though I check
the department... appreciate any help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Welcome to the Scripting Store</TITLE>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
<SCRIPT>
// Banner Rotator logic
//Load banner elements into array
var banners = new
Array("banner1.jpg","banner2.jpg","banner3.jpg","banner4.jpg")
//Set banner counter to 0
var bnrCntr = 0
//Function that actually rotates the banner
function bancycle() {
bnrCntr = bnrCntr + 1
if (bnrCntr == 4) {
bnrCntr = 0
}
document.Banner.src = banners[bnrCntr]
setTimeout("bancycle()",3000)
}
//End Banner Rotator Logic
</SCRIPT>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY onload=bancycle()>
<TABLE borderColor=blue width=700 border=1>
<TBODY>
<TR>
<TD width="30%"><IMG name=Banner></TD>
<TD align=middle>
<H1>Welcome to the Scripting
Store</H1></TD></TR></TBODY></TABLE><BR>
<SCRIPT language=javascript>
document.writeln("Today is: ");
var nDate = new Date();
document.writeln(nDate);
var strName = new String();
strName = window.prompt("What is your Name?", "FirstNameOnly");
//document.write("Welcome " + strName + "<br>");
document.write("<h2>Hello " + strName + "</h2>");
var varStatus;
status = "Hello " + strName + " - Welcome to the Scripting Store";
//Year(Now());
</SCRIPT>
<P>Please select one of our departments listed below</P><BR><INPUT
onclick=locateDepartment() type=button value="Select Department"
name=btnSelect>
<BR>
<SCRIPT>
var varDept = new Array(3);
varDept[0] = "Books";
varDept[1] = "Computers";
varDept[2] = "Caffeine free products";
var numMax = varDept.length;
var strDept;
for (var i=0; i <numMax; ++i)
{
document.write("<p><input type='checkbox' value=" + + "name=" +
varDept + ">" + varDept + "</p>");
}
</SCRIPT>
<SCRIPT>
function locateDepartment()
{
var varselect = true;
var varMax = 3;
for (var x=0; x < varMax; ++x)
{
if (varDept[x].checked == true)
{
if ([x] == 0)
{
location.href='book.htm';
}
else if ([x] == 1)
{
location.href='Caffiene.htm';
}
else if ([x] == 2)
{
location.href='Computers.htm';
}
}
else
{
varselect = false;
}
}
if (varselect == false)
{
window.alert("Please Select a Department");
return false;
}
}
</SCRIPT>
</BODY></HTML>