aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Created a function that will display what is written in textbox, but it is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Created a function that will display what is written in textbox, but it is not working" Watch "Created a function that will display what is written in textbox, but it is not working" New topic
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: 1056

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: 76

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: 12

.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: 76



Yes .value will extract the data from "text1" id.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Created a function that will display what is written in textbox, but it is not working