Click to See Complete Forum and Search --> : checbox question?


gasman
05-23-2004, 04:39 AM
Hi,

I am trying to check whether a checkbox is checked or not, if it is I will open the relevant url page.

I have looked at various samples and it appears that I need to state

document.form.name[counter].checked

My code is attached but I get an error on page.

If I try to debug in Dreamweaver I can ge to see form.name object but none of its properties after that.

Can someone please point out what I am doing wrong?

Before I started in Javascript, I *thought* I could program, now I am not so sure <g>


Code is below

<html>
<head>
<title>NTL Pages</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript">
<!--

var pfx="http://";
var tgt="_blank";
var arrName = new Array();
var arrUrl = new Array();
var arrDisplay = new Array();

arrName[0] = "sabs";
arrDisplay[0] = "SABS"
arrUrl[0] = "portal.sabs.private.ntl.com/";

arrName[1] = "iams";
arrDisplay[1] = "IAMS";
arrUrl[1] = "42.65.12.20/dtv/csa_start.html";

arrName[2] = "nexushome";
arrDisplay[2] = "Nexus Home Tab";
arrUrl[2] = "nexus";

arrName[3] = "data";
arrDisplay[3] = "ICMS Data Capture"
arrUrl[3] =
"nexus/content/popup.asp?url=/apps/forms/rescode_datacapture.asp&uid=2098"

arrName[4] = "nexusdept";
arrDisplay[4] = "Nexus Dept Tab"
arrUrl[4] = "nexus/content/departments.asp"

arrName[5] = "intranet";
arrDisplay[5] = "Intranet"
arrUrl[5] = "groupintranet/home/default.asp"

arrName[6] = "ufault";
arrDisplay[6] = "UBR Faults"
arrUrl[6] = "nexus/apps/ubrcheck/search.asp?launch=true"

arrName[7] = "pfault";
arrDisplay[7] = "Popup Faults"
arrUrl[7] = "nexus/content/popup.asp?url=http://trojan.private.ntl.com/apps/wbpu/outage/list.asp&uid=2112"

arrName[8] = "ifault";
arrDisplay[8] = "ICMS Fault Ticket Form"
arrUrl[8] = "nexus/content/popup.asp?url=/apps/forms/bromley_tickets.asp?type=stb&uid=2195"


function OpenPage(){
for (var i=0; i<arrName.length; i++) {
if (window.document.ntlstart.openit[i].checked) {
arrName[i]=window.open(pfx + arrUrl[i], arrName[i]);
}
}

}
function ClosePage() {
for (var i=0; i<arrName.length; i++) {
if (arrName[i] && !arrName[i].closed) arrName[i].close();
}
}

function WritePage() {
for (var i=0; i<arrName.length; i++) {
document.write('<p><input type="checkbox" name="openit" value="checkbox" checked><a href='
+ pfx + arrUrl[i] + ' target=' + tgt + '>' + arrDisplay[i] + '</a></p>')
}
}

//-->
</script>

</head>

<body bgcolor="#FFFFFF" text="#000000">
<p align="center"><font size="6"><b>NTL Start HTML Page</b></font></p>
<p>&nbsp;</p>
<p>Use the links below to open the web applications individually, and use
the
open button to open them all at once.</p>

<form name="ntlstart">
<p><input type="button" name="cmdOpenPage" value="Open Pages"
onClick="OpenPage()"></p>
<p>
<input type="button" name="cmdClosePage" value="Close Pages"
onClick="ClosePage()">
</p>
<p>&nbsp;</p>
</form>

<script language="JavaScript">
WritePage()
</script>

</body>
</html>

Fang
05-23-2004, 05:01 AM
Put the WritePage() function in the form block.

gasman
05-23-2004, 05:09 AM
Jeez, it was that simple.

I was checking the code for syntax errors and everything else.

Thank you Fang.

You are fast becoming my mentor <g>

Fang
05-23-2004, 05:16 AM
Pleased to help.
Just for correctness:
<script type="text/javascript">
//<![CDATA[
<!--
WritePage();
//-->
//]]>
</script>