Copy the query of GET to clipboard [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is it possible to copy the query of a form, which is using GET method, to the clipboard?
My aim is to have a button, which when pressed should copy the value in the black box to the clipboard so it is easily shared with someone else.
Edit: Not just asking about copying something into the clipboard, I am also asking about how to get the value of the GET query..

The GET parameters are only added to the submitted URL at the moment where the button is pressed, i.e. the form is submitted, so I don't think that 's possible directly (i.e. retreiving a value from the submit button)
But you could use a plugin like https://clipboardjs.com/, "collect" all the form data via JS and combine them together with the initial URL for its return value including the GET data.

this might help
var path = location.href.replace(/[^\?]+$/,$('form').serialize());
var cpy = $('input#cpy').val(path);
cpy.select();
document.execCommand('copy');

Related

Autofilling a different webpage with user input [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am trying to find out how I can make a program in JavaScript/HTML that takes a user's input and automatically enters this information onto a different web page. I am new to JavaScript/HTML so any help would be appreciated!
You specified the website as:
Supreme
Now, when you go to checkout, right click and click Inspect Elements. Then find all of the input fields on the website. For example, I found the Full Name input field. The field has a name: order[billing_name]
What you want to do next is in your URL do something like this:
https://www.supremenewyork.com/checkout?order[billing_name]=yourname
Now if you want multiple values (most likely) you need to find the names of the other fields and add the values to the URL, as so:
https://www.supremenewyork.com/checkout?order[billing_name]=yourname&order[email]=youremail
This way you can pass the values from your application and fill in the form on that website.
Hope this helps.
Use localstorage. see working demo in the link below;
Note: localStorage won't work in snippet; hence I made a fiddle.

if I were to click a button somewhere on a web page, I want specific text to appear in a specific form field [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
So for one of my classes I need to create a simple Web-App. In the index jsp page, I wanted to be able to click a button somewhere else in the page, causing this to automatically fill in a form field with a value, that would then be sent to the server.
So for example, if I clicked some button, I want text to fill in a search bar I created at the top of the page that reads "hello world" and also send that value to the server.
I am thinking I should be using Jquery's click() function. But I am unsure how to proceed from there.
Something like the following maybe?
$("#button").click(function() {
$("#input").val("My Text Here");
});
Of course you want to replace the selectors and text with what you actually want.
That basically says whenever a user clicks on #button set #input to My Text Here
#input being your text form field and #button being your button you want the user to click to display the text in the field.

ASP.NET change text with no page refresh on button click [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've found a couple other threads containing the same questions, but none of them had an understandable answer. I am supposed to make client side changes, but that is only possible in the .ascx file and if for instance i want to call a function to calculate something and then display it with no page refresh that is not possible :( any easy solutions?
With jquery, you can replace the contents of any existing HTML element using the .html() function. For example,
$("#MyDiv").html("Here is the new text.");
Since the function takes HTML as an input, you can even set the style if you want:
$("#MyDiv").html("Here is some text. <DIV class='foo'>Here is some more text in a different style.</DIV>");
You can also add new elements using .append(), like this:
$("#MyDiv").append("<p>Even more text</p>");
To do this upon a button click, you would use the .click() function. So your code would look something like this:
$("#MyButton").click(function() {
$("#MyDiv").html("You just clicked a button!");
});

Store a values using jquery and use it elsewhere [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Both file are html, index.html and show.html, in index.html i have a very basic form with a single input type="file", when user selects a file(only images) it shows a preview, when user clicks on "send" the user goes to the show page and I want to show on that page the image that was "uploaded", but since no images are uploaded because is just a demo with no actual uploading functions how do I show that image?... the jquery library that I use to preview the image in index.html converts the image in to a base64 code I'm able to get that value, but in show.html I can't use POST, and using ajax is out of the question, i was thinking to use:
document.getElementById("posted_image").innerHTML = window.location.search;
then just parse the value, but the problem is that the base64 code of that image is humongous it wont work... also I was thinking to store the value in a cookie but I don't know how to do that with javascript or if a cookie has a limitation... is there an actual way of doing this without the use of PHP?..
first you should convert the image into base64 as you did already so if you have value then use localStorage to store the image
localStorage.setItem("base64mgData", base64mgData);
here is the stackoverflow link

Pull data from database on click? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I was wondering whether it is possible in JavaScript (preferably jQuery) to pull data from a database using MySQL after clicking on a button? I currently pull data when the page loads, but I don't want to load 100's of items at the beginning as I want to be able to pull certain rows with different buttons?
<button class="AjaxTrigger" data-example="abc">I do ABC </button>
$('.AjaxTrigger').on('click', function(){
$.get("your-file.php", {example: $(this).data('example')}, function(result){
alert( "This is what php gave me: " + "\n" +result );
}
});
And now you let your-file.php do whatever you want, just like you normaly program you php files. Echo the outcome, and in javascript you will get exactly that in the returnfunction (which now alerts your result).
jQuery's full ajax, or jQuery's get (works easier)
Using jQuery to access data-* attributes
jQuery's eventhandling explained (event are eg: click, hover, keyup)
When to use GET or POST (<- Good to read for everyone)
And if you feel like upping your game:
Use jQuery's getJSON to send back an array to javascript ( echo with php's json_encode())

Categories

Resources