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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button to copy text

Status
Not open for further replies.

thecynicality

Technical User
Dec 29, 2004
48
0
0
US
How can i make a input or other type of button to copy a certain text when pressed?
 
Yup you want javascript questions in the javascript forum.
Even though you are dealing with html inputs, the work of copying values is going to be done via javascript.

Code:
<html>
<head>
<script>
function copyval(){
	document.getElementById("text2").value = document.getElementById("text1").value;
}
</script>
</head>
<body>
	<form id="myform">
	<input type="text" id="text1" value="">
	<input type="text" id="text2" value="">
	</form>
	<button onclick="copyval();">copy</button>
</body>
</html>
here you go.


I don't know the answer but my good friend Google does.
 
j4606, you know his question belongs in the javascript forum and that's why you decided to provide him with an answer here?
 
j4606, I think the OP is wanting something that will copy the information to the clipboard, not from one field to another.

-kaht

Looking for a puppy?

[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
 
[qoute]j4606, you know his question belongs in the javascript forum and that's why you decided to provide him with an answer here?[/quote]



My apologies. I guess I was too eager to provide users with help in exchange for purple lovin. I will try to keep on subject from now on. To my defense I had written my post before anyone else had and in my post i had directed him to the proper forum. Unfortunatly i was too slow to respond:<. I just didn't want to waste my effort so I posted my response anyway which originally had a possible solution and link to the javascript forum.
[noevil]


I don't know the answer but my good friend Google does.
 
[purpleface]

I don't know the answer but my good friend Google does.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top