Gytis is right, Javascript is the easiest way to perform this. Although you could have saved yourself some time with your original code and either used the existing API, or a http request to GETXML, GETJSON or similar. You can look at the Custom-JS-API javascript files for examples.
One change you may need to make to Gytis example is to use RS.Fields.Item("Field_Name").Value as just using RS("FIeld_Name") can cause issues in IE10.