I have drop down menu with various options
- New
- In Progress
- Ordered
- Not Ordered
- Completed
- Cancelled
I have a form which I need to hide the ETA row when status is new, then enable it for any other status. This is what I tried:
var progress, ordered, unordered, completed, cancelled, reg, high, user, trimUser, etaDate, etaRow, etaHour, etaMinutes;
function initiate() {
//declaring necessary variables
declaration()
}
function declaration(){
//Declaration of variables for status changes
sNew = $("option[value='New']");
progress = $("option[value='In Progress']");
ordered = $("option[value='Ordered']");
unordered = $("option[value='Unordered']");
completed = $("option[value='Completed']");
cancelled = $("option[value='Cancelled']");
//Declaring variables for priority changes
reg = $('input[value="ctl00"]');
high = $('input[value="ctl01"]');
//Declaring current user using SPServices
user = $().SPServices.SPGetCurrentUser({
fieldName: "Name",
debug: false
});
//Declaring variables for ETA field manipulation
etaRow = $("nobr").filter(function () { return $.trim(this.childNodes[0].nodeValue) === "ETA"; }).closest("tr");
etaDate = $('input[title="ETA"]');
etaHour = $("[id$=DateTimeFieldDateHours]");
etaMinutes = $("[id$=DateTimeFieldDateMinutes]");
}
function hideETA(){
//hide ETA options
etaRow.hide();
if(sNew.not(:checked)){
alert('CP1');
eta.show();
}
}
So the way I tried to do it was by initially hiding it (because new is the default), then when it's anything but new, show it.
EDIT:
I think I have it solved, this is how I did it after some help from @Richard with my if statement and selectors:
function setETA(){
//Hide, Display and Disable ETA based on stages
if(sNew.is(":checked")){
etaRow.hide();
}else if (progress.is(":checked")){
//do nothing, should be already showing
}else{
etaDate.attr("readonly","true").css('background-color','#F6F6F6');
etaHour.attr("disabled","disabled");
etaMinutes.attr("disabled","disabled");
}
}