How to find the ID of this HTML source - html

I want to find out the ID of an element. I want to find out the ID of the textbox because I need the ID to type into my VB application (from there I will use GetElementbyID to find the element). I tried "futPhishingTextBoxTyped" for the ID but it doesn't work..

The Textbox with the class of "futPhishingTextboxTyped" does not have an assigned ID. You need to refer to it from the FORM parent:
document.*formname*.futPhishingTextboxTyped (whatever your form name is)
INPUTS are also supposed to be self-closing:
<input class="futPhishingTextboxTyped" type="text" maxlength="15" />

It doesn't have an id. You could try getting the div and then finding children of it that are inputs with
GetElementById("futPhishingAdditional").GetElementsByTagName("input")
Going by your comment, the full line might look like this:
WebBrowser1.Document.GetElementById("futPhishingAdditional").GetElementsByTagName("input").Item(0).SetAttribute("va‌​lue", TextBox1.Text)

Related

Multiple form labels - Lightbox

I am editing html codes for web accessibility but I faced one problem about Multiple form labels. I am using Wave plugin to check web accessibility.
Errors is
Multiple form labels
What It Means
A form control has more than one label associated with it.
The problem is that there is a page user can input user info, and a button to call pop up then the pop up has all same fields again to register if user did not input the field.
Instead of changing ID of the field in popup, is there any quick and easy way to remove the error?
From W3Schools:
The id attribute specifies a unique id for an HTML element (the value
must be unique within the HTML document).
So yes, you need to define a unique ID for each and every component. This is the only clean way to solve your problem, otherwise a screenreader could read the wrong label when you focus one of your input fields.
One way to fix this other than changing IDs is to wrap the input in the label.
<label>
First Name
<input />
</label>
This is semantically correct and avoids the labels needing for and associated input id attributes.
You obviously might need to refactor some stuff and it seems like more hard work than just changing some IDs but that is an option (I know you will have probably fixed this by now, this is more for reference if someone else comes to this question.)
See: https://stackoverflow.com/a/774065/2702894

Select checkbox on website using VBA

I have an piece of VBA-code, to log in to a website.
This was quite easy, looking for the ID of the element, and use the code:
IE.document.getElementById("Postponement").Click
But now I get a problem, because the HTML code of a particular checkbox is only:
<input type="checkbox" data-bind="checked: selectAll, click: actionAllSelected"></input>
This is a checkbox to select all customers on this particular page. I want to select them all. Because there is no ID or NAME, I can not use getElementById.
Here is the checkbox, and the HTML code. If you want more information then let me know!
Anyone have an idea to select this checkbox with VBA?
try IE.document.getElementsByAttribute("Type")(0).checked="1"

Retrieve value from input to new input

I would like to retrieve an value from a different input to my button's input value.
I have an input, which is hidden and an input in which my costumers can change the value as they desire. I would like to retrieve this value and put into my hidden inputs value, when clicked on a button.
I've been adviced to use a OnSubmit code, but I'm not very familiar with it and can't seem to get it working, so I was hoping to meet someone who may help me.
The input in which I would like to retrieve the value from my other input is coded as shown:
input type="hidden" name="quantity"
The input in which i would like to retrieve value FROM is coded as shown:
INPUT TYPE=TEXT NAME="PROD_VK_1.4" SIZE=3 MAXLENGTH=3 value=1 onChange="CalculateTotal(this.form)"
You can retrieve value from the above input tag using the js function getElementsByName
It returns a collection of elements of the name specified.So if there is only one element you can access as the zeroth element by accessing zeroth index as if it is an array.See the below example
var input_val = document.getElementsByName("PROD_VK_1.4")[0];
To put the value to the hidden input use the following code
document.getElementsByName("quantity")[0].value = input_val;
More on getElementsByName
You should have an ID attribute on your hidden variable; suppose it is id="quantity". Also an ID attribute on the sending data will make things easier; make it "PROD_VK_1.4". Then, if you want the hidden variable to get a copy of the visible variable when the form is submitted, you'd code something like this:
<form action="whatever" onsubmit="moveData();" >
the moveData function would look something like this:
function moveData() {
document.getElementById("quantity").value =
document.getElementById("PROD_VK_1.4").value;
}
I haven't tested this, but if there are no fumble-finger errors, it ought to work.
If you didn't want to hook this to the submit event, perhaps you could edit your question a bit.
I am curious... why do you want to do this when you could just use the value of the original input element when the form is submitted?
If both of the <input>s have ids, you can do this:
document.getElementById('to').value = document.getElementById('from').value;
Here is an example:
http://jsfiddle.net/b2eDj/5/

Updating a form field with a link

I have access to form field in the administrative view.
Example
<label>Number:</label>
<input type="text" name="title" size="50"/><br/>
I do not have access to modify the html syntax, the only thing i can do is updating the form field with a value.
In the form field i want to update it with a number. I also want to have a link assigned to that number.
So when i click that number it directs us to the link.
Is there a way i can do that?
This method is tedious, but you could use the jQuery nth-selector to select the specific form element that you are dealing with.
http://api.jquery.com/nth-child-selector/
This method is risky, however, since you might add other form elements before it, altering the index of your target input element.
Afterwords, you could use the .val() jQuery method to change your input value.
Nonetheless, again, this method is not safe because the index of the form element could change. I would beg the powers of be to be able to add an ID or some identifying attribute to that form element.

With a hidden element, you reference the ID to get the posted value, what is name for then?

With a hidden element, you reference the ID to get the posted value, what is name for then?
Just wondering, do I even have to add that attribute in the HTML?
With any form element, including hidden type ones, only the name of the element is used to name the posted value.
You have to add the name attribute.
If you have
hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI#'
in your view, you'll access the value in your controller with
params[:token]
Is that what you're asking?