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
235 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 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now