How to select scanner by its name ?

Dynamic Web TWAIN offers a method named SelectSourceByIndex which allows you to select the index-the source in SourceNameItems property as the current source.
However, in some cases, you may want to select a source by the source name. There isn't such a method, but that can be achieved by a few lines of code.

Javascript Code:

for(var i = 0; i < DWObject.SourceCount; i++)
{
    var PSourceName = "7500"; //"7500" is part of your source name
    if(DWObject.GetSourceNameItems(i).indexOf(PSourceName) != -1) 
    {
    DWObject.SelectSourceByIndex(i);
    break;
    }
}

In the sample, we use a scanner named HP Scanjet Enterprise 7500. So you can use "500" as a key word.

You need to change the PSourceName accordingly. In order to select the right source as you wanted, make sure that the PSourceName is unique to all the source.