I have an HTML form with the method 'get'. When I click the 'submit' the action is to open a php file in a new tab. This is working properly and because I used 'get' I can copy/paste the URL and get back to the same page with the same variables from the form when I originally submitted it.
Now I am looking to add an additional button to the form but I would like it to copy the URL with all the variables to clipboard instead of opening the URL in a new tab.
I'm not looking for someone to write the code for me just point me in the right direction. Should I try to figure out a way to build the URL and then copy it to clipboard using Javascript? Would PHP make more sense?
I can post the code so far if someone thinks it will help but its really just a basic HTML form at the moment. Regardless of what fields, etc are in the form how do I build the URL with those fields?
I'm hoping that since it already builds the URL to redirect you there in the new tab there is someway to just grab that and copy it to clipboard without actually redirecting them.
EDIT
Question is getting marked as duplicate because other questions have answered how to copy simple text to a clipboard. I guess I wasn't clear enough in the original question, I would like to interrupt the form after it builds the URL, but before it redirects you to the URL. Then copy that URL to the clipboard. Might not be possible since I've done a lot of googling and haven't found anything on it. If someone can even just tell me if it is possible that would be greatly appreciated.
Perhaps the only way to do this is to build the URL myself then copy to the clipboard, which is fine but I wanted to make sure I wasn't missing something really simple like formtarget = 'clipboard' or something that just makes too much sense.