Im creating a automation using VB in microsoft Visual Studio like a app
the project path is Visual Basic>windows classic Desktop>windows form
app(.NET framework).
Code is written using VBA and it is a form which gets
user input and paste it into a webform and click a submit button and create a Ticket.
I already have this automation running via VBA excel. however due to some circumstances i need to create it as a standalone app instead. I have problem in clicking the submit button. can someone please assist me in putting the code right.
this is the HTML element taken from view source
<input type="hidden" name="ticket_type" id="ticket_type" value="" />
<input type="hidden" name="quicklink_id" id="quicklink_id"value="0"/>
<textarea name="work_log" style="display:none"></textarea>
<textarea name="correspondence" style="display:none"></textarea>
<div id="action_bar" class="cti-search-enabled">
<div id="button_bar">
<a class="tt_button orange_button" href="#" onclick="ajax_submit()">
<span>Submit Ticket</span></a>
<a class="tt_button" href="#" onclick="build_quicklink()">
<span>Save as New Quicklink</span></a>
as you can see there are two buttons, one is Submit Ticket and Save as New Quicklink. i need to click the Submit Ticket button. The earlier code is used in VBA is
Call sel.executeScript("ajax_submit()", "javascript")
This is my code in .net
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
Handles WebBrowser1.DocumentCompleted
MessageBox.Show("Document loading completed!")
Me.WebBrowser1.Document.ExecCommand("ajax_submit()", "javascript")
End Sub
so once the form is loaded, it will show a message box and then should click the submit button. however this is showing error as
Severity Code Description Project File Line Suppression State
Error BC30455 Argument not specified for parameter 'value' of 'Public Overloads Sub ExecCommand(command As String, showUI As Boolean, value As Object)'. My_First
Can someone help me on how the code should be. Sorry im a beginner in .net (and VBA as well)
This seems to do the trick:
Me.WebBrowser1.Document.All("ID-Of-The-Button").InvokeMember("Click")
Related
I load a webpage in a webView. In onPageFinished(..) i run some javascript code, which finally clicks a submit button. So the webView sends Post data and get an answer and loads a new page. That works fine, but i dont need the new page, its just unnecessary network load. I only need to submit the data.
So is it possible to send only the submit without loading the new page? I know that i can send post data with HTTPConnection, but i dont know the header consistence exactly, so i cant set the params. Is there any possibility with JS/Webview to abort?
Edit: I cant override onPageStarted() in my WebViewClient and perform a view.stopLoading(), because the new URL is still the same. But the site appearance is quite different. So i have to stop loading before
HTML of the submit button:
<input type="submit" name="savechanges" class="btn btn-primary" value="Speichern">
and three aditional lines above
<input type="hidden" name="uid" value="390">
<input type="hidden" name="option" value="com_jevents">
<input type="hidden" name="task" value="dash.listprojects">
which meaning i dont know (site is made by Joomla)
You can simply create a "virtual form" and submit it, like:
var $form = $("");
... on click:
$form.submit();
Hope this helps
Ops its removing my html from inside $form, inside the jQuery selector there should be a form like "form method='post' action='{someurl}'" with angle braces opening and closing properly
I have a main site, mainwebsite.org, and a sub-site that uses a different domain, mainwebsite.giftgiving.org that is styled to look the same as the main site so that users do not feel as though they've left the original site.
The main site has a search button, and I need that search button to work on the secondary site. However, I don't entirely understand how the submit function of the search button works, so I'm not sure how to get it working right on the secondary site. Simply copying the html didn't work, which I assume is because I'm either missing some javascript function or because the submit button is trying to post to a page that doesn't actually exist on the secondary site (I had a similar issue with a different website, where a submit button submitted to "../searchpage.aspx" but that page only existed on www.mainsite.org, so secondarysite.org/searchpage.aspx resulted in 'page not found'). As it is now though, I'm not getting any error, the search button simply doesn't do anything.
Here's the HTML from the main site:
<div id="ctl00_pnlSearch002" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl00_btnSearch002')">
<div class="utilities floatRight">
<ul>
<li class="searchButton"><input type="image" name="ctl00$btnSearch002" id="ctl00_btnSearch002" src="/images/design002/btn_search.jpg" style="width: 30px; height: 22px; border: none;"></li>
<li class="search"><input name="ctl00$txtSearch" type="text" id="ctl00_txtSearch" value="Search" onblur="if (value == '') {value = 'Search'}" onfocus="if (value == 'Search') {value =''}"></li>
<li class="paddingL">A+A-</li>
<li class="textsize paddingL">Text Size</li>
</ul>
</div>
</div>
I don't understand how this line works:
onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ct100_btnSearch002')
If I could figure out where the search button is making a call to, I could modify the secondary site by putting the search button inside a form with action="http://mainwebsite.org/?????"
That one line that you don't understand triggers a JavaScript function that in this case likely ends up performing a postback: WebForm_FireDefaultButton() performs a virtual "click" on the named element, in this case, "ct100_btnSearch002".
(There's a copy of the source code to that JS function here, although you can easily disassemble MS's helper JS yourself to see it: http://www.sentia.com.au/blog/fixing-the-enter-key-in-aspnet-with-jquery)
That button very likely performs a postback on the original page, triggering some "OnClick" event of the "btnSearch002" control. Since you've only shown the resulting HTML and not the original .aspx file it came from, or the .aspx.cs file that contains the server-side code that responds to that postback, it's going to be very hard to tell you much more.
But odds are pretty good that you can't simply copy that "search" button from site to site: Copying that markup is copying just the tip of the iceberg, and leaves out the rest of the berg that's holding up that tip.
I am trying to figure out how to make this HTML submit button work correctly. Below is the code for the submit button:
<form action ="itms-services://?action=download-manifest&url=https://icustomer.apsresource.com/ipad_apps/survey/user/APSSurvey.plist">
<button type="submit" name="Download" value="download" onclick="JavaScript:alert('You will be downloading the APS Resource iPAD PRODUCT SURVEY.')" style="width:255px; height:310px; -webkit-appearance: none; -webkit-border-radius:0px;">
<img src="apple.png" />
</button>
</form>
When the button is clicked, it is supposed to open up the URL in the "action" part in the form tag. However, all I get is the JS pop-up, but no URL is opened (looking at the console, a GET function is triggered, then instantly canceled). IS there something I need to add/remove in order for this to work?
Submit the form with the onclick event
onclick="alert('You will be downloading the APS Resource iPAD PRODUCT SURVEY.');this.form.submit();"
You don't need to put the work JavaScript in your event either.
BTW, you don't really need to have this.form.submit() at all. I took your original and removed JavaScript from the onlick and changed the action and your code works fine. I'm not sure what itms-services:// is but it's not a valid HTTP protocol like http:// or https://.
Here's a jsfiddle illustrating this.
I've noticed today that my link that usually popups up a paypal light box for digital goods express payment has stopped working. The link was working as recently as the 2012/11/21, and I checked that the problem exists on a server that contains old code (that used to work), so I don't think that this is something that I have changed, but rather something that paypal has changed in their js files.
The code I use is exactly what is generated by the paypal wizard:
<!-- INFO: The post URL "checkout.java" is invoked when clicked on "Pay with PayPal" button.-->
<form action='checkout.java' METHOD='POST'>
<input type='image' name='paypal_submit' id='paypal_submit' src='https://www.paypal.com/en_US/i/btn/btn_dg_pay_w_paypal.gif' border='0' align='top' alt='Pay with PayPal'/>
</form>
....
<!-- Add Digital goods in-context experience. Ensure that this script is added before the closing of html body tag -->
<script src='https://www.paypalobjects.com/js/external/dg.js' type='text/javascript'></script>
<script>
var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her 'Remember me on your computer' option.
});
</script>
Firstly, when the page now loads, there looks like there's some noise on an image named 'nameOnButton' (the 'image' contains the text 'su yi' with a few empty boxes) that the PP javascript must insert, as it is not in the HTML that I generate. Various examples on the web also have this spurious image. The HTML looks like:
<form action="/pay/dpSetCheckout/" method="GET" target="PPDGFrame">
<input type="hidden" name="express">
<input type="hidden" name="trackingNumber" value="UNg0000306">
<span class="nameOnButton"><img src="https://www.paypal.com/webapps/checkout/nameOnButton.gif"><br><input type="image" name="paypal_submit" id="paypal_submit" src="https://www.paypal.com/en_US/i/btn/btn_dg_pay_w_paypal.gif" border="0" align="top" alt="Pay with PayPal"></span>
</form>
...
<script>
$(document).ready(function(){
var dg = new PAYPAL.apps.DGFlow({
trigger: 'paypal_submit',
expType: 'instant'
//PayPal will decide the experience type for the buyer based on his/her 'Remember me on your computer' option.
});
});
</script>
When I click on the 'pay with paypal' button, the screen 'shades to grey', but the paypal popup never appears. After about 5 seconds the error message 'Refused to display document because display forbidden by X-Frame-Options.' appears in the javascript console, most probably because the lightbox was not created. I don't think this is a back end/configuration problem, because if I open the 'pay with paypal' link in a new tab, it opens up fine.
I'm not quite sure where to start debubgging this (seeing that there aren't any javascript error messsages).
I think there was a bug with Japanese and Chinese language fonts in recent PayPal release and it should be fixed soon
I have a page on which a list of properties is displayed (i.e houses). This list is made up using CSS. So I've built a second CSS class, which makes the properties/houses align properly in 2 columns. Until now I did this by pressing a button, posting back, and outputting different html (basicly the same, but with other Css class references).
Now I found this question on SO and I implemented a basic scenario. A div with the class "yellow" is written to the html page, and a button changes this class to "red". This happens, but the div immediately changes back to class "yellow".
I'm a very very beginner in JS but not a beginning programmer. This would be a great addition to my site, but I can't find a proper answer. I apologize if this question is redundant.
<script type="text/javascript">
function changeView() {
document.getElementById("box").className = " red";
}
Grtz, thanks in advance, Christophe,
By default a button element is of type 'submit' - which will cause your browser to post back to the server.
Try changing the type to button instead.
<input type="button" ....
More info on the difference here... Difference between <input type='button' /> and <input type='submit' />
If your button causes a postback (possibly a server control with an asp: tag), the javascript changes you made will be lost as by default an asp button submits a page to the server as a result of which your page reloads.
If all you need to change the class of a div make it a simple html button like
<input type="button" onclick="changeView()" value="Change" />