How do I return the value of an argument? [RESOLVED]

I would like to get the value of my argument in the following code for global use. Any ideas how I get severity?:

// temporarily show alert when starting edits
// and then start listening for a map click
var startCaptureRequest = function (severity) {
var listener;

    // NOTE: once user has clicked 'x' to dismiss  
    // this alert, it will no longer show up  
    domStyle.set(app.startEditAlert, 'display', '');
    setTimeout(function () {
        domStyle.set(app.startEditAlert, 'display', 'none');
    }, 3000);
    // save map point in app global and  
    listener = app.map.on('click', function (e) {
        listener.remove();
        // save map point in app global and  
        // show form to collect incident report  
        app.currentGeometry = e.mapPoint;
        
       
        if (severity == 0) {
            alert("This will show the signs form.");
        } else if (severity == 1) {
            app.attributesModal.modal('show');
        }
        
        
    });
    
   
};

You mean the value of ‘severity’?

var severityVal;
var startCaptureRequest = function(severity){
    severityVal = severity;
   ...
    return severityVal;
    }

HTH,

:slight_smile:

1 Like
  1. Define a variable outside any functions (i.e. create global variable);
  2. Inside your function pass value of argument to that global variable;
  3. Use global variable in any other place.

Actually, this is what @WolfShade did in his example above.

Thanks. I wanted to mark it as answered, but don’t see a link for that. I did like it though.

There isn’t a direct way, per se, to mark as resolved. However, if you can still edit the TITLE of the thread, you can manually add [RESOLVED] to the title, if you like.

V/r,

:slight_smile:

Done.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.