Skip to main content
Known Participant
August 18, 2020
Question

Couple of question

  • August 18, 2020
  • 1 reply
  • 389 views

1. How to use "else" without if?

example:

var sum1 = this.getField("field1").value;

var sum2 = this.getField("field2").value;

var total = sum1+sum2;

event.value = total;

else event.value = "";

 

2. In custom dialog box how to make "cancel" or "other" button do the same as "ok" button?

example:

 commit: function(dialog)
{
var data = dialog.store();
this.strName = data["usnm"];
},
butn: function(dialog){
this.strName = data["usnm"];
},

but it does nothing.

if I set it like this:

butn: function(dialog){
dialog.end("butn");

then it works, but I want it to do same as "ok" button.

 

This topic has been closed for replies.

1 reply

Legend
August 18, 2020

You can't, and your question makes no sense to someone who knows what else is for ... I think you're trying to copy a part of something you don't understand. Under what ACTUAL situation would you want to set event.value to "" ? Because I assume you don't want to do it every single time. So, what you need is an if.

MarietaaAuthor
Known Participant
August 18, 2020

I know what else is for, was just asking in my example above how would set without if, field value to "" if there is no calculation.

Legend
August 18, 2020

But there IS a calculation. It's these three lines:

var sum1 = this.getField("field1").value;

var sum2 = this.getField("field2").value;

var total = sum1+sum2;

These will always happen. You need to define (because programmers need to be exact) just what you really mean by "no calculation". For example do you mean 

* field1 and field2 are both blank?

* field1 or field2, either one or both is blank?

* the result from adding up field1 and field2 is zero

* something else?

If you can answer this with accuracy, the code will probably be simple (and will have an if in it).