?
Solved

vbscript: i keep getting an error with this and i dont know why..any help would be great thanks

Posted on 2004-08-01
4
Medium Priority
?
262 Views
Last Modified: 2010-05-02
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Check Boxes</title>
<script>
function checkAll(objCheck){
     objForm = document.forms[0];
     if(objCheck.checked){
          bolChecked = true;
     }else{
          bolChecked = false;
     }
     for(i=0;i<objForm.elements.length;i++){
        if(objForm.elements[i].type=="checkbox"){
                  objForm.elements[i].checked = bolChecked;
         }
     }
}

function checkBoxes (chkBox) {
  var theCheckBox="chkBox"+chkBox.id;
  if(chkBox.checked) {
    document.getElementById(theCheckBox).innerHTML='Install';
  }else{
    document.getElementById(theCheckBox).innerHTML='Do Not Install';
  }
}

function CheckSome(){
    document.frmChecks.chkCheck_3.checked = true;
    checkBoxes("3");
    document.frmChecks.chkCheck_5.checked = true;
    checkBoxes("5");
}

function pageInit(){
  CheckSome();
}
</script>

</head>
<body onLoad=pageInit()>

<td>
<form action="http://www.fairfieldconsulting.com/processForm.asp" method="post" name="frmChecks" id="frmChecks">

  <input id="1" type="checkbox"  name="chkCheck_1" onclick="checkBoxes(this)"><span id="chkBox1">Do Not Install this program 1</span>
  <br>
  <input id="2" type="checkbox"  name="chkCheck_2" onclick="checkBoxes(this)"><span id="chkBox2">Do Not Install</span>
  <br>
  <input id="3" type="checkbox"  name="chkCheck_3" onclick="checkBoxes(this)"><span id="chkBox3">Do Not Install</span>
  <br>
  <input id="4" type="checkbox"  name="chkCheck_4" onclick="checkBoxes(this)"><span id="chkBox4">Do Not Install</span>
  <br>
  <input id="5" type="checkbox"  name="chkCheck_5" onclick="checkBoxes(this)"><span id="chkBox5">Do Not Install</span>
  <br><br>
  <input type="checkbox" name="chkCheck" value="" onClick="checkAll(this)">Check / Uncheck All<br />
  <br>
  <input type=button onClick="CheckSome()" value="Default">
  <input name="Reset" type="reset" onclick="checkBoxes(this)">
  <input name="MySubmit" type="submit" onClick="VBScript:MsgBox('Submitted!')">
</form>
</td>

</body>
</html>
0
Comment
Question by:Johnny
  • 3
4 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 11690743
function CheckSome(){
    document.frmChecks.chkCheck_3.checked = true
    checkBoxes(document.frmChecks.chkCheck_3);
    document.frmChecks.chkCheck_5.checked = true;
    checkBoxes(document.frmChecks.chkCheck_5);;
}
0
 
LVL 33

Accepted Solution

by:
sajuks earned 2000 total points
ID: 11690745
the whole script,
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Check Boxes</title>
<script>
function checkAll(objCheck){
     objForm = document.forms[0];
     if(objCheck.checked){
          bolChecked = true;
     }else{
          bolChecked = false;
     }
     for(i=0;i<objForm.elements.length;i++){
        if(objForm.elements[i].type=="checkbox"){
                  objForm.elements[i].checked = bolChecked;
         }
     }
}

function checkBoxes (chkBox) {
 var theCheckBox="chkBox"+chkBox.id;
  if(chkBox.checked) {
    document.getElementById(theCheckBox).innerHTML='Install';
  }else{
    document.getElementById(theCheckBox).innerHTML='Do Not Install';
  }
}

function CheckSome(){
    document.frmChecks.chkCheck_3.checked = true
    checkBoxes(document.frmChecks.chkCheck_3);
    document.frmChecks.chkCheck_5.checked = true;
    checkBoxes(document.frmChecks.chkCheck_5);
}

function pageInit(){
  CheckSome();
}
</script>

</head>
<body onLoad=pageInit()>

<td>
<form action="http://www.fairfieldconsulting.com/processForm.asp" method="post" name="frmChecks" id="frmChecks">

  <input id="1" type="checkbox"  name="chkCheck_1" onclick="checkBoxes(this)"><span id="chkBox1">Do Not Install this program 1</span>
  <br>
  <input id="2" type="checkbox"  name="chkCheck_2" onclick="checkBoxes(this)"><span id="chkBox2">Do Not Install</span>
  <br>
  <input id="3" type="checkbox"  name="chkCheck_3" onclick="checkBoxes(this)"><span id="chkBox3">Do Not Install</span>
  <br>
  <input id="4" type="checkbox"  name="chkCheck_4" onclick="checkBoxes(this)"><span id="chkBox4">Do Not Install</span>
  <br>
  <input id="5" type="checkbox"  name="chkCheck_5" onclick="checkBoxes(this)"><span id="chkBox5">Do Not Install</span>
  <br><br>
  <input type="checkbox" name="chkCheck" value="" onClick="checkAll(this)">Check / Uncheck All<br />
  <br>
  <input type=button onClick="CheckSome()" value="Default">
  <input name="Reset" type="reset" onclick="checkBoxes(this)">
  <input name="MySubmit" type="submit" onClick="VBScript:MsgBox('Submitted!')">
</form>
</td>

</body>
</html>
0
 

Author Comment

by:Johnny
ID: 11690817
thank you for posting the complete script too...

i couldnt figure it out

thanks alot
0
 
LVL 33

Expert Comment

by:sajuks
ID: 11691003
Thanks for the points and grade
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question