Input Field with text already populated on page load - html

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.

Related

Displaying long value within a disabled text input

I have an input field of type = "text". At the time of entering the details into the input, I can enter a long input. The value is getting stored appropriately in DB as well. After clicking on a submit button, I am disabling the field.
So input is still visible but with only the value (noneditable). The problem arises here as only the length of text box input is being displayed.
Is there any way in which the entire input will be displayed?
One way to do this is instead of disabling the input box, you just remove the onChange event on the inout field and style the text to look like its disabled. if onChange event is something like this:
onChange={() => ()}
It won't be able to change the value of the input field, as it has an anonymous function.
That's one of way of doing it.

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')
});

Is there any way to override a mailto field with another field?

AKA, if I have two fields (one radio button group and one textarea that only appears if the "other" radio button is pressed) how would I make it so the input from the text area overrides the "other" button having it's value placed in the mailto?
E.g., I want this to happen:
field1=text from text area
NOT this:
field1=other
field2=text from text area
Could I set the value of the "other" radio button in field1 to the text coming from the text area?
Alternatively, could I do anything to prevent a certain field from appearing in the mailto fields?
In future, please ensure you present SO with a code issue, not a general question or request. However, you would use a JQuery change handler, like so:
$('#mastertextboxid').on('input', function(){ //executes every time master's text is updated
$('#slavetextboxid').value($('#mastertextboxid').text()); //updates the values
})
This will overwrite any text in the slave textbox when the master textbox is changed, but the User will still be able to input into the slave textbox. It's known as One way data binding.

Can't remove the value entered in the djFilteringSelect dojo control in xPages

I am using the djFilteringSelect control to show values in a dropdown as user type a value.
The lookup and typehead is working fine. The user type a letter and the dropdown allow the user to select a value which is then displayed in the dropdown field.
If the user now decide to remove the value first selected so that the combobox is empty and leave the field, then the first value in the list is now automatically filled in.
The consequence of this is that if the user have added a value there is no way to remove the value and leave the box emtpy.
I am using required=false for both the control and the dojo attribute but it does not seem to help. There are also a few other djFilteringSelect attributes I have tried like "Autocomplete" and "trim" but it does not work
Here is the code
<xe:djFilteringSelect id="test" type="select" store="jsondata" searchAttr="data" required="false" labelType="html" invalidMessage="Not valid">
<xe:this.dojoAttributes>
<xp:dojoAttribute name="required" value="false"></xp:dojoAttribute>
</xe:this.dojoAttributes>
</xe:djFilteringSelect>
Initally the field is not required, but if the user have entered a value it is required.
My question is if there a way to prevent the djFilteringSelect control to always populate the field if I have previously added a value
I found someone who solved this in another stack overflow topic, by creating an empty entry in my data store. but I could not get this to work
Dojo: Select of empty value for FilteringSelect while required=false
I do this quite a lot. Right now I don't have a working sample to show you (since I moved to bootstrap - and have to code the selects by manually adding select2 controls) but something like this should do it...
I add an "empty" value at the top of my select - and that seems to work no matter whether I am using a combobox, djCombobox or combobox with select2 from bootstrap. My markup typically looks like:
<xp:comboBox id="inputLocationSelector" value="#{User.catchListType}" disableClientSideValidation="true">
<xp:selectItem itemLabel="(none)" itemValue=""></xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[${Configuration.meta.listLocationTypeOptions}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
Then you could specify "(none)", "All" or " " for the "not-selected" value depending on your needs.
Validation is a different thing so just specifying "required=false" does not give you the "empty" value.
/John

How do I edit a text field in Selenium 2?

I can type text into a field using WebElement.sendKeys() but editing doesn't work: I can neither move the cursor nor delete the last character that I typed with e.sendKeys( Keys.BACK_SPACE )
How do I modify the value of a text field in Selenium 2 (WebDriver)?
You can definitely do that by either of the two methods. I have tried and it works.
e.click() # Positions the cursor at the end of the string
e.sendKeys(Keys.BACK_SPACE )
Or you could simply clear the text, and start over again:
e.clear()
e.sendKeys("What you want to send")
I found this solution that seems to work pretty well. It basically clicks on the text field WebElement, then sends Ctrl-End to put the cursor at the end of the text. Then sends the string that I had previously initialized.
(quickReplyTextArea is a text field WebElement that I have previous found, as is postQuickReplyButton (button instead of text field, obviously). replyText is a String that I initialized earlier)
quickReplyTextArea.click();
quickReplyTextArea.sendKeys(Keys.chord(Keys.CONTROL, Keys.END));
quickReplyTextArea.sendKeys(replyText);
postQuickReplyButton.click();
You can try clicking first into that text box, and use sendKeys() afterwards.