Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing text to form fields 1

Status
Not open for further replies.

harrysdad

Programmer
May 30, 2002
53
GB
I am building a simple page to enable addition of news items to my intranet via a form submitted to the database.

I want the user to be able to click buttons that add text to a textarea - e.g. they can click a button to automatically write empty html tags and links with "almost" complete urls in them.

Can anyone help out? My javascript is pretty basic.
 
Something like this:

Code:
<script type="text/javascript">
function addURL(url) {
	document.forms[0].news.value += '<a href="' + url + '"></a>';
}
</script>

And then:

Code:
<form action="page.asp" method="post">
<input type="button" value="Add URL 1" onclick="addURL('page1.html');" />
<input type="button" value="Add URL 2" onclick="addURL('page2.html');" /><br />
<textarea name="news" cols="40" rows="10"></textarea><br />
<input type="submit" value="Add news" />
</form>

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top