It seems to me that you could know ahead of time (when the page with the button is being generated) if they have set the fields, so that you wouldn't have to have the button do a check. But when the button is pressed, you could have it open a small "custom page" in another window, so then you could follow the instructions in this article:
https://vborg.vbsupport.ru/showthread.php?t=228112
As for the fields, you could just use an html form with whatever type of fields you need for them to fill in. You would need another custom page to handle the submission of that form, but what you'd probably want to do is use the same custom script and have a "do" parameter, so that if do is set to a certain value you know the form is being submitted, otherwise you just display the form.
Anyway, I hope this helps.