Use VB.NET WebBrowser Control to update text field - html

I have an HTML form that I would like to fill in automatically. There is one field in particular that I am having trouble with and it has following HTML code:
<input type="text" name="add1" size="13" maxlength="12">
As you can see it does not have a value attribute that I can manipulate directly so have to resort to something else. I use the following code to get the desired element:
Dim element As HtmlElement = WebBrowser.Document.GetElementsByTagName("input").GetElementsByName("add1").Item(0)
This works fine but when I try to use element.InnerText() = "foo" the OuterHtml updates to include the new text (value="foo" to the HTML above) but element.InnerText is stll equal to Nothing and when the page is shown to the user the text element still has no input. So what do I need to do to get the text input to show in the proper field?

Related

Get value of HTML5 input type search from code behind after postback in .NET

I'm creating a sample textbox for search like this (I'm using VB) in my webpage:
Dim txtSearchFilter As New HtmlGenericControl("input")
With txtSearchFilter
.ID = "txtSearchFilter"
.Attributes.Add("placeholder","Filter")
.Attributes.Add("type","search")
.Attributes.Add("maxlength","80")
End With
It's great, because this is the HTML5 style box which has some useful features, such as the "x" on the right side of the box to clear the text entry. However, from the code behind, I can't retrieve the text that was entered. I've tried:
txtSearchFilter.InnerText
txtSearchFilter.InnerHtml
txtSearchFilter.Attributes("value")
Request.Form("txtSearchFilter")
But none of these work. Is there a way to get the value?
P.S., SO prevents me from selecting the HTML5 tag and, instead, puts in the HTML tag even though I selected the HTML5 tag.
Add a name attribute to the input element.
txtSearchFilter.Attributes.Add("name", "txtSearchFilter")
Then on postback, you can retrieve the value by Request.Form(name_attribute). Example based on the above code :
Dim value as String = Request.Form("txtSearchFilter")

How do I use a CSS attribute's value of an html element as input when submiting a form with Django?

Please first click the link to the image below to understand my question/situation.
If the text below a particular species icon (circle with animal image inside it) is bold, I would like that to be used as input criteria for getting information from a database. In other words, I want to use the font-weight CSS property of a "< p >" element as an input. Only one "species text" can be bold at a time.
For example, if I have "D. rerio" selected (its font is bold) and I click the "search" button, I would like for the back-end to know that it needs to pull information from the "D. rerio" database specifically.
Rather than trying to send the value of the CSS, you should use the same process that sets the CSS to set a value in a hidden field. Something like:
<input type="hidden" name="species" id="id_species">
...
$("#fishIcon").click(function(){
$("#fishIconText").css("font-weight", "700")
$('#id_species').val('fish')
});

Input Field with text already populated on page load

I have a custom Visual Force page that on load has a name field that is supposed to have {Auto} printed inside the input text box that the user can delete or leave or not. I have been using a html-placeholder however the text just disappears and is gray.
My VF inputfield:
<apex:inputfield required="true"
value="{!EventPackageRevenueBreakdown__c.Name}" html-placeholder="{!Auto}"></apex:inputfield>
What it looks like with that code:
What I need it to look like (notice the cursor is after the closing scope)
Thanks in advance I'm still very new to this!
I suggest you to set Name field in controller with '{Auto}' value.
The placeholder attribute will disappear when there is a value in the field, what you want is to actually set the VALUE of the field to {Auto}.
Try this:
If you want it to automatically clear the field if a user clicks into it, you could add some javascript to handle that.

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/

how to format the hint displayed inside a html form field?

There was a question previously on how to show hints in a text field (html form field), which clears automatically when the user clicks on the field under consideration. As in, when the field gets focus, the hint displayed inside the form gets cleared without the user having to manually delete the characters.
The solution given (and it works perfectly) -
<input onfocus="if (this.value=='search') this.value = ''" type="text" value="search">
Now my question is, how do you format the text that is displayed as the hint (in this case "search"). By formatting, i would want it to be in a certain color and font type.
I can do this to the other fields, which do not have this preloaded hint in it, by using css-
color:#123123; font-family:calibri;
Thanks!
You're asking about styling the content (value) of an input element.
You can use regular CSS for this:
input {
color:#123123;
font-family:Calibri;
}
Working example: http://jsfiddle.net/fxxp4/