Jump to content
Sign in to follow this  
s_avinash_s

input text not printing properly

Recommended Posts

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

output.PNG

Edited by s_avinash_s

Share this post


Link to post
Share on other sites

You need a <textarea> element for that. <input> elements only support single-line text.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

If "logview1" was a textarea, the code you have right there would work just fine.

Share this post


Link to post
Share on other sites

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>

 

Share this post


Link to post
Share on other sites

Set the value property of the textarea to an empty string when the button is clicked.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×