How to show automatically Caret at the end of new added text to the textArea? - html

I have TextArea component. In different situation i should append text to it.I want Caret to be appears at the end of new appended text and if text is to large, automatically scrolling down.

You can do this with java script.
Given you have a form named "f" and a textarea named "q" this puts the caret inside it:
function sf(){document.f.q.focus();}
Dont forget to call the method somewhere for example:
<BODY onLoad=sf()>

Related

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.

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.

Unable to get the updated text of text box

I've one text box and one update button:
Text box:
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
update button:
<asp:Button ID="btnUpdFName" runat="server"Text="Update" onclick="btnUpdFName_Click"/>
What I am doing in page load event I am getting the first name from database and assinging it to text box as follows:
txtFName.Text = dt.Rows[0][1].ToString();
Now when i earases the text set at page load event in text box as above and write another name and press update button, i am trying to get the new text entered in the text box in the button click event as follows:
string FName = txtFName.Text;
But the problem is that every time I write new text in text box, I am still getting the same text as set form database (dt.Rows[0][1].ToString()).
I am not able to get the current text from the text box and getting only the intial value set from db in page load event.
What I encountered that after compilation my text box markup becomes as follows:
<input id="CPHcontent_txtFName" type="text" value="value set from db i.e. dt.Rows[0] [1].ToString()" name="ctl00$CPHcontent$txttxtFName"></input>
the text box alway has the same value set from the db. Thats why i am getting each time the same value regardless of value entered by user in text box.
Now tell me how to get the updated value of text box in my page behind.
Thanx in advance
In asp.net webforms you should separate code for setting data to control and for saving data to db. One of ways to set data to control - use check
if (!IsPostBack)
{
txtFName.Text = dt.Rows[0][1].ToString();
}
in page load event.
Otherwise you will overwrite your newly entered text for textbox on every page load.
You are probably overwriting the text you entered in your Page Load event, because you are not checking if it is a PostBack.
Please read ASP.NET Page Life Cycle Overview for further information.
Set the textbox to empty or null before you try to set/read it again onpageload.

Actionscript3; make a dynamic text box show text while hovered

I'm trying to create one of my first actionscript3s...I want to make a dynamic text box (dynText) write a description of what the hovered button (stopButton) does.
No text is shown when I hover the button and I get no error message. Why?
This is my code
dynText.addEventListener( MouseEvent.MOUSE_OVER, myInfoHandler )
function myInfoHandler( event ){
if(event.target.name == "stopButton"){
dynText.text = "Stop animation!";
}
}
And just to make sure it isn't the text fields fault: to make a dynamic text field do I just create a text field and choose "Dynamic text" in the dropodown?
I've tried too google and read other answers but I guess I'm too much of a noob to understand...
Try changing this line:
dynText.addEventListener(MouseEvent.MOUSE_OVER, myInfoHandler);
to this:
stopButton.addEventListener(MouseEvent.MOUSE_OVER, myInfoHandler);
You want the listener to trigger when the button is moused over, not the text field, so you need to add the listener to the button itself.

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.