HI,
Here's the code that I've changed so far.
- <html>
- <head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- </head>
- <script>
- $(document).on('click', '.copy', function(e) {
- var serialized = $(this.form).serializeArray()
- var text = serialized.map(function(field) {
- return field.name+": "+field.value
- }).join("\n")
- $("#copy").show().val(text)[0].select();
- document.execCommand("copy");
- $("#copy").hide();
- alert("Copied the form: " + text);
- return false
- })
- </script>
- <form>
- <label>Name: <input type="text" name="Name" value="" size="30"></label><br>
- <label>Address: <input type="text" name="Address" value="" size="30"></label><br>
- <label>Phone #: <input type="text" name="Best Phone #" value="" size="30"></label><br>
- ********************<br>
- <label>Model: <input type="text" name="Model" value="" size="30"></label><br>
- <label>SN: <input type="text" name="SN" value="" size="30"></label><br>
- <button class=copy>copy</button>
- </form>
- <textarea id=copy name="hide" style="display:none;"></textarea>
- </html>
When clicking copy in the form created. It will paste it like this:
Name: Test
Address: Test
Best Phone #: Test
Model: Test
SN: Test
I need to have it pasted as: -
Name: Test
Address: Test
Best Phone #: Test
***************************
Model: Test
SN: Test
So it's like how the form looks like.
Hoping someone could help out.