Print to specific printer using VBScript? - printing

I'm trying to have users fill out an HTA form, submit it (which will CC them a copy) and have it automatically print to a specific network computer that will only be used for this purpose.
I was able to get the form to basically print the window by using the following code:
<input style="margin-right: 5px;" type="button" name="Print" value="Print" Onclick="print()">
However, that just brings up the print dialog box that makes me choose a printer, and people won't be able to select this printer I need to use.
I've looked and tried a few things, but this has been the only thing that has worked so far. I don't want users to be able to change anything (number of copies, etc.). I just want it to print their input once they click "order".
Thanks!!
-EDIT-
I tried using "window.print()" as the OnClick event of the submit button, which would work, but it just brings up the print dialogue box for users to choose a printer. I need it to just automatically print it out.

Related

Call function onClick ASP.NET Core

I have a dropdown menu that show a list of files saved on disk:
It works fine but when you think about it, I have to load all the links/docs every time someone goes on the page.
What I would like to do is to have some sort of onClick function so that it would load / get the files only when asked so when I click on the 'a' tag.
I tried to add an onclick="nameOfmyFunction" but that does not work.
Could you give me some tips to achieve this? Or is it even possible?
Edit:
That is not it. I want to load al my files when I click on the "Consulter les conventions" which is the first <a class="dropdown" data-toggle="dropdown"> tag.
So I tried something like this :
If the user click on the "conculter les conventions" then I load my files and create my dropdown menu else do not create the dropdown menu.
But I get the error that (when I try it) the function is not defined.

Filling in a search box and then clicking on the autocomplete

I am having trouble filling in and clicking this search box
<input type="text" name="js-emu-operation-search" id="js-emu-operation-search" placeholder="Enter service name" autocomplete="off">
I have tried using
internet.fill_in('js-emu-operation-search', :with => "Alternator Replacement")
but it does not work. After that is filled in though I am also wondering how to click on the first autocomplete option.
Working with autocompletes can be pretty difficult, depending on how it's implemented. Some tricks I've used in the past:
Click the input before sending text to it
find('#js-emu-operation-search').click()
Try using the underlying element methods instead of the fill_in wrapper, e.g.
find('#js-emu-operation-search').set("Alternator Replacement")
Select from the dropdown options with find("#results-pane", text: "My Result").click, or if you get really desperate, make sure there's only a single result and select it with the down arrow, find('#js-emu-operation-search').native.send_keys(:arrow_down)
Disclaimer: My capybara is getting rusty, may have to tinker. If you're working on a team, I've also had good luck dragging another developer into it, preferably the guy who implemented the autocomplete.

Clicking checkbox using capybara

Currently I have a checkbox wrapped by a label.
<label for="exercise_form_division_ids_34">
<input class="check_boxes optional division-checkboxes" type="checkbox" value="34" name="form[division_ids][]" id="exercise_form_division_ids_34"> Technology
</label>
In my integration test I tried to use
within '.organizations' do
find("label[for='exercise_form_division_ids_34").click
end
OR
check "exercise_form_division_ids_#{department.id}", allow_label_click: true
But I still get this nable to find visible checkbox "calltree_exercise_form_division_ids_2" that is not disabled
Unable to find visible checkbox "exercise_form_division_ids_" that is not disabled
With the limited info provided you have a few potential possibilities.
The label/checkbox aren't actually inside an element with the class of the organizations on the page.
The error Unable to find visible checkbox "exercise_form_division_ids_" that is not disabled shows that no id is actually getting inserted into your selector which would tend to indicate that department isn't actually persisted in your test.
You may be assuming 34 is the correct id based on what it is in your dev environment but that may not be what it is in your test environment.
To narrow down the possibilities the first thing to do would be to grab a screenshot in your with test with page.save_and_open_screenshot (assuming you're using a driver which supports screenshots) and make sure there is actually a visible checkbox on the page. If not, you're probably not creating the required objects in the DB prior to your test starting.
Secondly look at the page in your browser and make sure the elements visible on the screen are actually the checkbox and/or the label. If both label & checkbox are being hidden and replaced with some JS widget then you'd need to interact with whatever elements the widget creates in the page (just like a user would). If only the checkbox is being hidden via JS/CSS but the label is visible then
check('Technology', allow_label_click: true) # check matching on label text
should work.

aria-live on textarea not working with JAWS

I am using html textarea to simulate a command prompt. On typing a command command (e.g. ipconfig) and hitting Enter key, the command output gets appended to to the text. To read the output I have added aria-live="polite" attribute to the textarea which works fine with NVDA screen reader. However, JAWS on IE, starts reading from the top every time a command is entered. How do I make it read only the newly appended text like NVDA does?
So far I have tried aria-relevant="additions", role=log, role=alert attributes but nothing seems to work.
enter code here
<textarea id="commandPrompt" aria-live="polite"
rows="5" cols="45" wrap="off" spellcheck="false">
</textarea>
IN theory, you should be able to define precisely what should be read using aria-relevant and aria-atomic.
Unfortunately, Jaws doesn't follow standards very well. These two attributes are known not to always work as expected with Jaws, depending on the browser used, the element to which they are applied, etc.
This is probably not the answer you wanted to have, but if Jaws doesn't do what you expect, the only solution is most likely to put the text to be spoken in another element.
In a div or span you are much more mikely to have the expected behavior.

submit button behaviour in IE

I have a problem in IE. Hitting enter when the focus is on the last input control sends the focus to the "Next" button. This submits the form. So far, so good.
The code in my base class WizardController looks to see if the Next submit button is null, as follows:
protected string NextButton
{
get
{
return ControllerContext.HttpContext.Request.Params["NextButton"];Nex
}
}
However, despite the form submitting, this property returns null unless the user explicitly clicks on the button with his mouse.
This is blatantly wrong, but I have no idea why it is happening.
EDITED TO SPECIFY THE PRECISE PROBLEM:
The problem only occurs IF there is ONLY one TEXT input control in the HTML form that gets rendered to the browser.
END EDIT
Andrew
I have finally found an explanation for my problem:
It seems to be a bug in IE, whereby if there is a single text input in the rendered HTML form, then IE will not submit the form properly. The issue is described (briefly) at:
Form Submit via Enter Key when using IE
In the above link, no description is given as to why the bug occurs, or since what version of IE, so a blanket solution is better.
The workaround suggested in the article is to add a css hidden text input (with conditionals for IE):
<!--[if IE]>
<input type="text" style="display: none;" disabled="disabled" size="1" />
<![endif]-->
This worked for me, so issue solved.
The following is included to document the issue as I experienced it:
Unlike the problem described in the article, my form did submit. However, when I tried to check which button had been accessed by hitting tab or enter key, no submit button was in the HttpContext.Request.Params collection. So the behaviour I saw was slightly different.
What the above article did identify is that this behaviour is only seen WHEN there is ONLY one text input control. A single check box, for example, does not cause the problem.
I hope that this documents the problem adequately... and that MS will one day correct the bug.
A simple work around might be to use a hidden form element and depend on that rather than the button.
<input type='hidden' name='action' value='next' />
If you have multiple buttons you can always use JavaScript to change the value of the action element just before submitting.

Resources