Can you post the code you are using?
It is probably worth mentioning that changing a CRM form element with JavaScript into a button isn't supported. A better and supported way might be to create an HTML web resource file with an input button that fires of the required JavaScript code. This web resource can then be placed on your form.
Or additionally you could also create a ribbon button that calls a method from a JavaScript file as another option.