URL form retrieval and submission via flash? - html

Totally new to flash and actionscript. What I want to do is retrieve a URL into a page (probably in a hidden frame or something), populate the form it contains with the correct fields (via my script), including possible data to upload, then submit it back. I guess an analogy use-case would be if I had a user choose a picture and then which site to upload it to (tinypic, flickr, etc), the script would download the main page, fill in the form data, attach the pic, and submit it. I saw a similar example in php somewhere, but I need to do it in flash.
I can probably get it eventually by myself, but if someone could point me in the right direction (keywords, functions to use/avoid, etc) I'd really appreciate it!

Rather than retrieving the form and trying to fill it out just use actionscript to directly post to the server side script.

Related

VBA webcontrol automation problem with inputfield

I'm an accountant and I develop a lot of automation to carry the repetitive task of my job. I've been fairly successful with most of them, but I got stuck with some code I can't find the solution to and probably it's just a simple thing I should already know.
So it's like this, I used to use selenium and make the code open an IE instance and navigate, login, fill multiple fields, select radio buttons etc. But I was using this with sendkeys function and Tab.
Now I reviewed all the code and implemented a webbrowser element to a userform and I'm using HTMLdoc to interact with the webpage, the objective of the app is to open the website, fill the invoice information then send and save the file, right now I'm able to login and navigate to the new invoice page.
The problem starts here, I use this code to get the text to the input fields on the webpage:
HTMLDoc.getElementsByName("dataInicio").Item(0).Value = Controlo_Arrendamento.txt_dataInicio
HTMLDoc.getElementsByName("dataFim").Item(0).Value = Controlo_Arrendamento.txt_dataFim
HTMLDoc.getElementsByName("dataRecebimento").Item(0).Value = Controlo_Arrendamento.txt_novoData.Text
HTMLDoc.getElementsByName("valor").Item(0).Value = Controlo_Arrendamento.txt_novoPago.Text & ",00"
HTMLDoc.getElementsByClassName("btn btn-sm btn-success").Item(0).Click
What happends is, when the submit button was pressed, the website gives me an error in every field, then I realized that when the data is inputed on the website normaly it automaticaly updates other elements on the webpage, it goes through some validation, so when my code inserts the values on the textbox it doesn't trigger, only by typing the values in...
So, I tried to dig everywhere for a solution, I watched the HTML elements and what changes when the value is valid and it's checked, tried implementing a .checked = true but no solution.
Anyone knows what I can do to get trough this?
I could send you the webpage but it needs a login and since it's a nacional finances website I'm afraid I can't share with you any login, but I will leave here the website in question, it may help figuring out what type of form i'm interacting with.
https://www.portaldasfinancas.gov.pt
Thanks in advance

CakePHP - refresh element/view cell using ajax

I'm trying to build a way to update a user profile one question at a time.
Essentially I want a div on my page that displays a form that lets the user submit the most important information, say firstname. When that has been filled out (success on the form) I want to refresh that div and show the second most important form, for say lastname, or if that is already filled in then birthday and so on.
Much like linkedin prompts you to add one more piece to your profile.
How would you do it?
My first thought was to use elements. But I need to fetch existing profile data to populate the form and how would the element get that data, abusing requestAction is not an option.
So I guess I in that case need to call a controller action that determines which element should be rendered, renders it to a variable and submits that (response->body) in json to the js that updates the page. Seems a bit .. unclean but should work.
Then we have view cells. They seem ideal for the task until I want to call them via ajax. That is not possible right?
So how would you go about to build something like that?
A form that needs to have the ability to be prepopulated with data if there is any and then refreshed automagically to display the form for the next piece of info needed.
View cells can't really be used in AJAX requests. This is not what they thought for.
The best thing you could do, if you want to keep the cell, is to make sure you followed SoC properly and put all your business logic into the model layer.
Now have a separate controller and action that is reachable from the outside throught a request (a cell is not) and return the data as JSON from there using the same code.
You could try to instantiate the cell in the controller action as well and send it's output. But honestly, I think that's a pretty fugly way of doing it.

click through several links on webpage and extract information from each?

I have access a webpage with a list of several hyperlinks, each of which are unique. This is it:
webpage I have access to that lists names from top to bottom. Each name is unique and is a hyperlink. I would like to click on these hyperlinks one by one and extract info from the resulting webpage.
Say I click the first name, say Adam, it then brings me to the following webpage:
alt:this is a page of the user's profile and includes info such as name, email status and more
My goal is to create a program that clicks the name at the top, and then takes the email address and puts it in an excel spreadsheet on my local machine. And then goes back to the original page, clicks on the name directly below the name that was previously clicked on, and then takes this names resulting email and throws it in the spreadsheet.
for those looking at the pictures, i would like to click on 'Adam' and then put his email into a spreadsheet, then go back, and then click on 'Adrian' and then put his email into a spreadsheet, and so on and so forth down the list.
What do I need to do/learn to create a tool that will do this for me?
I know a bit of Java and a tiny bit of html. I've been trying to look for a solution but the most I can get is excel vba to click on the first name, but not much more. Even if I got the vba to click on all the names, it seems I would have to type in an instruction for the vba to find each unique name, and I dont see much point in doing that since its probably faster to just do this manually then.
As i'm not a programmer (but would like to be soon :)) I have had some trouble asking this question since I don't know any technical terms.
Any thoughts/advice on how to do this?
With javascript and a little php you could make this happen. Since it appears this is something running in the browser it would probably be your best bet.
Make your program click links js has the ability to activate links. You could
click on body load
the first link on the page,
then have a counter that counts each time you click a link.
`Find out how many links there are in the document:`
var x = document.links.length;`
`Get the URL of the first link (index 0) in the document:`
`var x = document.links[0].href;`
Click the link you want to click
$(function(){
$('#myLink').trigger('click');
})
now that your on the next page you need to grab the email address that is on this page. If you know the css just grab the string that is in the element. at this point you can use javascript to go back to the previous page.
<button onclick="goBack()">Go Back</button>
Now you are on the original page. Your counter is one number higher. Use the counter to click the next link and your program will repeat the process pushing the new email to your array.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
once the program runs out of links to click or hits the limit of your counter you will need to create a txt file with javascript. write your array to the file with PHP. You can do this with an ajax call.
make an AJAX call to your php file passing the array. php can then write to the file.
Here is an example of making a text file and writing to it with javascript
Following this logic you can fairly easy make an application that activates the links in order of a page, pushes the email address to an array as a string. Goes back to the previous page and continues the process till you have all the links. At this point your program will write all the data in the array to a file.

GWT HTML Report Printing

I am currently working on a GWT application that requires report
printing. The use can select report parameters from a screen, and
upon clicking print we would like to display the file as it is being
generated. Currently we have server side code that is generating HTML
and writing it to a file. When the user clicks print, an RPC is being
made to pass the report parameters to the server and begin the
report. A second RPC is made after the report has started to obtain
the report's URL. From here, we are creating a Frame and setting the
URL to be the URL retrieved by the second RPC.
The issue I am running into, is that when setUrl gets
called, it only displays as much HTML that was contained in the file
at the time of the call. What would be the best way to refresh just
the frame containing the HTML report? It appears making subsequent
calls to setUrl passing in the same Url each time would do the trick,
but it actually doesn't seem to contain the additional content that
would've been written since the last call. It is also resetting the
vertical scroll bar's position each time back to the top of the bar
which is something else I would like to prevent.
Is there a better way to go about doing this?
I think it would be better to request HTML in chunks from GWT and render them as they arrive. Doing this with ajax instead of wholesale refreshes will enable better behavior with the scrollbar, eliminate flashing, get around caching problems, and will also let you add some feedback like a progress bar, estimated time remaining, etc.
There's a lot more infrastructure required for this, but your suggested solution doesn't seem quite appropriate for the task.

Creating "are you sure?" popup window by using html only

Assume I have a html from, and it contain some submit type. I want to create a "are you sure" popup window that will appear when user click submit button.
My question is that is there any way to create it by using "only" html, not using javascript or any other?
HTML only is possible, but not without a postback
Scenario that could work without javascript:
You have your form with submit button
User clicks (and submits) the form
You display another form with are you sure? form (that contains Yes and No buttons as well as hidden fields of the first form that will make it possible to do the action required on the original data
functionality that executes the action and goes back to whatever required.
This would be completely Javascript free, but it would require several postbacks.
This kind of thing is usually done on the client with a Javascript confirm() function (here's a simple example) or lately with a more user friendly modal dialog provided by many different client libraries or their plugins.
When to choose the script free version?
If you know your clients are going to be very basic ones (ie. vast majority of your users will access your application using clients like Opera Mini that's not able to run scripts at all). But in all other cases it's much better to do this using Javascript. It will be faster, easier to develop and much more user friendly. Not to mention that it will put less strain on your server as well since certain parts will execute on the client without the need of any server processing.
No, there isn't. Despite of the new features in HTML 5, HTML is still a markup language, not a programming language. In order to express dynamic behavior (such as an "are you sure?" box), you need to use a programming language.
Javascript would be the most obvious choice for this, but you could also do it with frameworks that can get you around writing Javascript by hand (for example ASP.NET).
Edit: Actually it appears that it would theoretically possible to do this with without Javascript or other frameworks. As I just learned, HTML 5 + CSS 3 seems to be turing complete. But this is hardly relevant to this question.
It's possible to ask for a confirmation, but it will not be in a "popup window". The creation of the "popup window" requires javascript/other language.
It will be:
Request (first form)
POST
Response (confirmation form)
POST
Response (outcome message)
You can create a form with all hidden elements containing the data from the first form and a "Yes" and "No" button below the "Are you sure?" text. You can use PHP sessions to avoid the hidden form elements. If there is a lot of data or confidential data or you do not want to re-validate the data from the second form, use sessions. Make sure you validate the data from either form before using it.
I know I'm like .. 10 years late. But for anyone still wondering I thought I could be of some help!
What I did for this exact problem was make sure I had multiple "divs" in my code. For me specifically, I had two main ones.
First, one whose id="main", and another whose id="popup" with the 'visible' property initially set to 'false' for the popup div.
Then, on whichever event you're looking for (button click for example) you'll simply set main.Visible = false and popup.Visible = true, then you could have more buttons in your popup (yes, no, cancel, confirm, etc.) which do the exact same thing, but in reverse!
The most important thing to make sure of is that you have the 'runat="server"' property in your divs so that you can access them in your CS code
Hope this was helpful! :)