I am trying to find a way to prefill an external HTML form with data and then click "Submit" using Javascript. I do not own the website that the form is on, so that makes things difficult. Is there any way to do this?
You actually can`t click other people's website using JavaScript. Maybe you can try something using an AJAX calls to send info but its out of the scope of this answer.
If you really plan to click Submit on someone's else form, you can look to headless browsers to fill this purpose. They can access the DOM and manipulate events such as click, load, etc.
Related
I want to build a website in which users can add information, like craigslist. I want the website user to be able to click a button fill out a form and add another box. For instance, if there is a three by three grid and the user clicks on the add button, I want a form to appear, them to fill it out and one more box to be permanently added to the grid. Of course I could make it happen with Javascript and JQuery but it isn't permanent. Thanks:)
You can Implement this using server side languages like PHP /Node JS, ASP.net, Java, Ruby or you can use Local Storage of the browser (this gives limited storage capacity ). read this for more details. link
If you don't already know PHP, you will need to learn it for this. Also, you will need to make sure that you understand how to validate input because letting users add to your database can be a very dangerous thing to do if you don't understand how things like script injection works.
I am trying to write a function that opens a new browser window and populate the email and login field and then click the submit button all from Javascript.
Lets say my domain is mynewweb.com and I want to open facebook.com/login page and populate the email and password fields from javascript code (such as document.getElementById) and then submit the form using some javascript code as well.
Is there any way of achieving that, any ideas. At the moment I am unable to achieve that I think its CORS issue but i'm not sure. But any idea of achieving that functionality or out of the box approach or something would be helpful.
Thanks
If I understand right, then you want a function that's not based on websites, but on browser functionality.
There are plenty of form filling plugins for different browsera, just look on their addons page.
I am trying to take on a new project creatively. Basically, I have a website where I want to put a custom form and a hidden iframe which will contain its own form. What I want is that when I press the submit button on the page's form, the values of say the text boxes will be passed to the iframe's form's text boxes and then submit the hidden form and display in a visible iframe the results.
I have looked through other questions, but none seem to have the same goal as I.
Is this possible? If so, how? I would highly appreciate any help.
nvncbl
If I've understood you correctly, you want to pass some input parameters without the page reload. If so, then you should dig into ajax in order to call asynchronously different parts of the web page.
Fortunatelly there are many frameworks that can help you. I prefer Knockout.js, but you can use for instance Angular.js or Backbone.js and so on.
I have such a problem - I want to change value of an element on some external website.
Namely: I have webcam http interface which is password protected and there is a page with motion detection checkbox and "Apply" button (form submit). I want to create simple program with some sort of delayed toggling of motion detection (so I can launch this program and have some time to leave the building before motion detection starts). So I want to change checkbox state and write this change to system. I tried something like this, but that doesn't work:
jQuery.get("http://admin:password#192.168.0.1:12345/motion-page.asp",
function(data){
$('input[name="checkbox1"]').prop('checked', false);
// and there "simulate" clicking on Apply button - submit the form -- don't know how ...
}
);
Can anybody help me with this, please?
I would backtrack from the page that shows when you submit the camera form. See if the form itself is submitting the "turn camera on" variable as GET or POST. If you already know this, then all you would have to do is access the same URL as the form from the camera (assuming it's HTTP accessible on a network like this) and submit that same set of variables.
If you don't want to open a browser to do this, you could write yourself a custom application that submits it for you, but either way you have to open something to make the submission, as a script has to wait [X] amount of time before making the request. The fastest way will be through a browser.
I am not sure you need jquery for this (I never use jquery hardly at all). What I would do on the scripting side, since merely accessing this script means you want to activate the timer most likely, would be to create a timer object in javascript, and then make a single function that either accesses the URL of the camera form submission with the GET string parameters (that's easiest if it's doable via GET, because you wont have to build a form), or, if it's POST, have the function build a form and submit the form via POST to the same URL.
Google how to create a timer in javascript, and google how to automatically submit a form. Doing the code for you would be a waste of my time if you can figure it out on your own. If not, come back and we'll see what we can do :)
Good luck.
Why not after hitting the submit button, or after checking the box, have javascript actually run a timer? Look into the timer functions in js or jquery if that's more your thing. Not sure if you need it written to disk or whatever... since you're not giving much info, but whatever data you're wanting recorded could be captured when the box is checked and can be submitted along with the form whenever the timer runs out.
Submitting a form in jquery is simple:
http://api.jquery.com/submit/
:)
I am working on learning JQuery and creating a simple HTML / JS calculator. I used a standard HTML form to allow the user to enter the data they want calculated and when the user clicks submit my JS / JQuery calculates and spits out the answer.
My question is what would be the semantically correct way to deal with the HTML form action being that Im not actually posting any data? I dont want to leave it default because when I click my to trigger an event it changes the URL and I dont want to use POST because Im not posting anything. Any help is appreciated!
I would replace the submit button with a normal button, and prevent the form being "submitted" at all. then use javascript to do the calculations on button click. This way the form never gets submitted, and you don't need a method or action at all.
If you really want to do a request at all, you probably just want to do a GET...check the list of HTTP request methods here to see if another one would better fit your needs.
If you are doing everything with javascript, though, you shouldn't be submitting anything at all. Try changing the submit button into a link (or just a regular button) and bind your calculator logic to its click event.
Don't specify any action(Default is GET). Use an html button which would call the js function on the click event. That would do the work on client side
You don't actually need to put input elements inside a form. Since you don't intend to submit the form, I would just omit it entirely.