s_avinash_s Posted October 23, 2018 Share Posted October 23, 2018 (edited) Hi I am using a input text ., am getting a data from a text file from sd card and trying to print in a text box using onclick event. <!DOCTYPE html> <html> <body> <form action="/action_page.php"> First name: <input type="text" name="FirstName" value="ABCD ABCD 1234 wert 2345 9988 12345678 " size="100" style="height:200px;font-size:14pt; overflow: scroll;"><br> <input type="submit" value="Submit"> </form> </body> </html> My text file has similar data s mentioned in "value".I mean data is in different line but my output is in single line shows as in attached image. 1. my requirement is, to get the data exactly as in file(line by line) or as mentioned in value 2.i need a scroll option when data exceeds Edited October 23, 2018 by s_avinash_s Link to comment Share on other sites More sharing options...
Ingolme Posted October 23, 2018 Share Posted October 23, 2018 You need a <textarea> element for that. <input> elements only support single-line text. Link to comment Share on other sites More sharing options...
s_avinash_s Posted October 24, 2018 Author Share Posted October 24, 2018 Hi Thanks for the reply. <p id="logview"></p> <script> function logview() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("logview1").value = this.responseText; } }; xhttp.open("GET", "log1.txt", true); xhttp.send(); } </script> <button onclick="logview()">View the log</button> I am using above code , i have a data in log1.txt file. How can i display the data in log1.txt file into " textarea". Please suggest Link to comment Share on other sites More sharing options...
Ingolme Posted October 24, 2018 Share Posted October 24, 2018 If "logview1" was a textarea, the code you have right there would work just fine. Link to comment Share on other sites More sharing options...
s_avinash_s Posted October 25, 2018 Author Share Posted October 25, 2018 Hi with that i am able to do it. Now it works. But am deleting a file , by using a delete button. How to clear the before read data present in textarea to get clear when delete button is clicked <textarea id="eventlogview1" rows="4" cols="50"> </textarea> <button onclick="Eventlogdelete()">Delete Event log</button> Link to comment Share on other sites More sharing options...
Ingolme Posted October 25, 2018 Share Posted October 25, 2018 Set the value property of the textarea to an empty string when the button is clicked. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now