Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Checkbox Isn't Checked....

Status
Not open for further replies.

jiggyg

Programmer
Oct 1, 2007
61
US
Hello List!

I have a checkbox on my page; and if the box isn't checked, I want to do a check on my form...

Checkbox code:
Code:
<input type="checkbox" name="validException" value=1
  <%
  if trim(Request.QueryString("validException")) = "YES" then 
    Response.Write " checked"
  end if
  %>
 > Valid Exception
</input>

Then in my 'chkForm' function where I'm checking the values/data in the form... I want to see if it's checked, if not, do a check on the capacity numbers...

This is what I have, but am getting an 'Object Expected' error:
Code:
function chkForm(){
  var doSubmit = true;
  :
  :
  //if checkbox is not checked, do the capacity check
  if document.forms[0].validException.value!=1{
    if ( (parseInt(document.forms[0].refurnCapacity.value)) < (parseInt(document.forms[0].currentCapacity.value)) ){
	alert("Refurnished Workplace Capacity cannot be less than Current Capacity");
	return;
    }
  }
  selectAll();
  document.forms[0].submit();
}

What am I doing wrong???

If I comment my 'if document.forms[0].validException.value!=1' statement out, the error is going away...

Thanks much for your time and expertise!
-jiggyg
 
Hi!

Got it... one issue was I didn't have parentheses around my condition in my if stmt (duh!)

Got it working with this:
Code:
//if checkbox is not checked, do the capacity check
 if (document.forms[0].validException.checked == false){
   if ( (parseInt(document.forms[0].refurnCapacity.value)) < (parseInt(document.forms[0].currentCapacity.value)) ){
        alert("Refurnished Workplace Capacity cannot be less than Current Capacity");
	return;
   }
}

Thanks for your time! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top