rpaterick Posted July 16, 2009 Share Posted July 16, 2009 I need the code below to state the opposite as it is currently. If the field does not contain the value "Commercial," then return value. if (Field("version").indexOf(String("Commercial")) > -1) { return "<span>" + Rule("Day of the Week") + "</span>"; } return "";Thanks! Link to comment Share on other sites More sharing options...
Dan Korn Posted July 17, 2009 Share Posted July 17, 2009 I need the code below to state the opposite as it is currently. If the field does not contain the value "Commercial," then return value. if (Field("version").indexOf(String("Commercial")) > -1) { return "<span>" + Rule("Day of the Week") + "</span>"; } return ""; The simplest way to turn an if/else statement (which is basically what this is, although you're using a return statement to imply the "else") into its "opposite" is to simply swap the "if" and "else" blocks, like so: if (Field("version").indexOf("Commercial") > -1) return ""; //else return "<span>" + Rule("Day of the Week") + "</span>";Or, you can change the logic in the comparison thusly: if (Field("version").indexOf("Commercial") [color=Red]==[/color] -1) return "<span>" + Rule("Day of the Week") + "</span>"; //else return ""; Link to comment Share on other sites More sharing options...
rpaterick Posted July 17, 2009 Author Share Posted July 17, 2009 The simplest way to turn an if/else statement (which is basically what this is, although you're using a return statement to imply the "else") into its "opposite" is to simply swap the "if" and "else" blocks, like so Nice! Thanks Dan! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.