Tuesday, July 14, 2009

How do I insert text in a text area in HTML web pages?

I want to design a web page where I could click on a hyperlink to insert a word in a text box or text area. I know I have to use Java script. But how?



How do I insert text in a text area in HTML web pages?





Hi,



Below is another way of doing it...



%26lt;html%26gt;



%26lt;head%26gt;



%26lt;meta http-equiv=%26quot;Content-Type%26quot; content=%26quot;text/html; charset=windows-1252%26quot;%26gt;



%26lt;title%26gt;Setting Textvalue using JavaScript...%26lt;/title%26gt;



%26lt;script language=%26quot;JavaScript%26quot;%26gt;



// Function to set the value of text box when user clicks on the link



function setTextFieldValue() {



document.frm.text1.value=%26quot;Yahoo Answers%26quot;;



}



%26lt;/script%26gt;



%26lt;/head%26gt;



%26lt;body%26gt;



%26lt;form name=%26quot;frm%26quot; method=%26quot;POST%26quot;%26gt;



%26lt;a href=%26quot;javascript: onClick=setTextFieldValue();%26quot;%26gt;Click Me%26lt;/a%26gt;



%26lt;input type=%26quot;text%26quot; name=%26quot;text1%26quot;%26gt;



%26lt;/form%26gt;



%26lt;/body%26gt;



%26lt;/html%26gt;



Your form fields should be within form tag to be able to set the value...



Cheers!!!



jAY



How do I insert text in a text area in HTML web pages?



do a search in google for document.getElementById. that will give you a host of resources and examples on how to access and manipulate the controls inside of a document.

No comments:

Post a Comment