tags:

views:

70

answers:

2

How do you force a limit total? Is this correct syntax? or am I missing something cause it's exceeding total number from my calculation.

 switch (ddlVal) {

case RequestTypes["Sick"]:
case RequestTypes["Late"]:
case RequestTypes["Jury Duty"]:
    tbEffectiveDate.disabled = false;
    ddlTotalHoursEffect.disabled = true;
    tbFromDate.disabled = true;
    tbToDate.disabled = true;
    cb.disabled = true;
    cb.checked = false;
    approvalRequired = false;
    commentsRequired = false;
    $("#spnDayOff").hide();
    break;

case RequestTypes["Day Off"]:
    tbEffectiveDate.disabled = false;
    ddlTotalHoursEffect.disabled = true;
    TotalHoursEffect <= 241  //THIS IS THE PART I WANT TO LIMIT DATA.
    tbFromDate.disabled = true;
    $("#spnDayOff").show();
    break;
default:
    break;
A: 

Are you trying to disable the tbFromDate if TotalHoursEffect <= 241?

// Force the TotalHoursEffect to be limited to 241
if (TotalHoursEffect > 241) {  //THIS IS THE PART I WANT TO LIMIT DATA.
    TotalHoursEffect = 241;
}
John Saunders
yes, and that's ok. I just need the TotalHoursEffect column to be limit or less than 241 value.
Kombucha
can i mix CASE statement and IF statement within? I've never done that but is that possible?
Kombucha
Yes, it is. Just make sure you have: "if(...){ ... }". Keep the { and } matched.
John Saunders
A: 

First things first, this is not c#. Please retag this item as javascript and jQuery as that's what it appears to be.

So what exactly are you trying to accomplish here? The subject says "FORCE limit data". What does that mean?

Lemme take a wild guess case RequestTypes["Day Off"]: <~~~ some control was acted upon and "Day Off" was chosen, now you want to disable a dropdown??? tbEffectiveDate.disabled = false; ddlTotalHoursEffect.disabled = true;

I don't believe these are true/false. I think "" is enabled and "disabled" is disabled. Then you have "ddlTotalHoursEffect <= 241 " If a drop down list is less than or equal 241???? I think (if ur using jQuery) you would set a variable equal to the integer value of the dropdown.

var totalHoursEffect = parseInt(ddlTotalHoursEffect.val());

then you can compare that to the 241? if totalHoursEffect <= 241 dosomething()

Thats about as far as I can go with this. Looks to me like you really want validation. You need to write some kind of function or set a variable to inspect later

Like this var thisIsValid = (totalHoursEffect <= 241)? true: false;

Then you would inspect thisIsValid to see if the user can continue.

Hope this helps.

Hcabnettek