| Author |
Created a function that will display what is written in textbox, but it is not working
|
Vishal Hegde
Ranch Hand
Joined: Aug 01, 2009
Posts: 973
|
|
Dear Ranchers,
Below is the html code saved in abc.html
where Am i going wrong?
|
http://www.lifesbizzare.blogspot.com || OCJP:81%
|
 |
RatiKanta pal
Ranch Hand
Joined: Nov 13, 2011
Posts: 50
|
|
HI,
<!DOCTYPE html>
<html>
<head>
<script>
function copyText()
{
document.getElementById("field2").value=document.getElementById("field1").value;
alert("hiii");
}
</script>
</head>
<body>
<form name="hello" onsubmit="">
Field1: <input type="text" id="field1" value="Hello World!"><br>
Field2: <input type="text" id="field2">
<br><br>
<input type="button" onclick="copyText()" name="click" value="click">
<p>A function is triggered when the button is clicked. The function copies the text in Field1 to Field2.</p>
</form>
</body>
</html>
And in your code var x=document.getElementById('text1').value part is missing
thank you.
|
 |
Alok Agrawal
Greenhorn
Joined: Feb 01, 2008
Posts: 11
|
|
.value is missing is line no. 8, it should be like:
|
Alok Agrawal
Learn Thru PPT Sports Info
|
 |
RatiKanta pal
Ranch Hand
Joined: Nov 13, 2011
Posts: 50
|
|
Yes .value will extract the data from "text1" id.
|
 |
 |
|
|
subject: Created a function that will display what is written in textbox, but it is not working
|
|
|