18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Need help with Dropdown list: How to pick latest value from dropdown.
we have a bunch of dropdowns on the web page. All these dropdown items are having numeric (Ex: 800,809,818 etc...) values and strings. Here i need to count the values from the dropdown and have to pick max value in the dropdown. Hey this is urgent. Please help me out.
Tagged:
This discussion has been closed.
Comments
Please elaborate with an example.
More info on javascript sorting
We have an internal application LMS in this application we are having 2 pages those are Leave Application and Leave Modification Request. After successful requesting a Leave one number will be generated (Leave Request No) and this will be available in the Leave Modification Request page under Leave Request No dropdown. Here I want to select Leave Request No which was requested earlier means latest Leave Request No from Leave Request No dropdown list.
Note: we don’t know the latest Leave Request No until unless selecting the dropdown list in the Leave Modification Request page.
Did you try the code in my previous reply? I think if you do it should work. Change "leaveReqNo" to the identifier of your select box.
Regards,
Narayan
i have tried with the following but i am getting null value. i am not getting dropdown list max value.
function GetMaxValueInDropDown($selectEl)
{
var opts = $selectEl.options; // get the options
var $values = []; // blank array
for (var $i=0; $i<$opts.length; $i++)
{
var $num = parseInt($opts[$i].value); // get the integer value of string
if ("" + $num != "NaN") // check if it is a number and add to array
{
$values[$values.length] = $num;
}
}
return values.sort(function($a, $b){return $a - $b;}).pop(); // sort it ascending numerically
and return last value.
_alert($values);
_setGlobal("LeaveRequestDDMaxValue", $values[0]);
}
We have an internal application LMS in this application we are having 2 pages those are Leave Application and Leave Modification Request. After successful requesting a Leave one number will be generated (Leave Request No) and this will be available in the Leave Modification Request page under Leave Request No dropdown. Here I want to pick Leave Request No which was requested earlier means latest Leave Request No from Leave Request No dropdown list.
Note: we don’t know the latest Leave Request No until unless selecting the dropdown list in the Leave Modification Request page.
Are the options in the dropdown visible as numbers when you look at them? If yes, there is a small change needed in the function.
Btw, you have to use the code as is. No need for modifications. Remember to use the browser tags for that function.
Regards,
Narayan