In 2011, it was the Ribbon's job: I assume 2013 would be the same (despite the different look'n'feel).
You had to use CrmParameter
to have the IDs of the selected records:
// in the RibbonDiffXml
<JavaScriptFunction FunctionName="YourFunc" Library="YourLibrary">
<CrmParameter Name="MyRecordIDs" Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>
//The corresponding function would look like
function YourFunc(recordIDs){
// recordIDS will be filled with the IDs of the selected records
}
Here is the reference for CrmParameter (it says it applies to 2011 but there is no equivalent for 2013 so I believe this info is still valid)
On a side note, never use getElementById
(it's not supported: no support from microsoft and any rollup might break your code).