0

I hav a google published csv sheet. I created a html table and want to display csv values from published csv sheet into all input fields inside html table.

due to a unspecified reason this question has been moved.

11
  • 1
    xmlhttp.responseText.trim(); so you need to split it up..... Commented Jan 6, 2022 at 16:37
  • 1
    @epascarello I don't' know how to do it. Can you please post your code? Commented Jan 6, 2022 at 16:39
  • You can use split() function. example : let splitedResult = xmlhttp.responseText.split(" "); console.log(splitedResult[0].trim(), splitedResult[1].trim()). You can assign the values to element.value = splitedResult[0].trim(); element1.value = splitedResult[1].trim() ...... Commented Jan 6, 2022 at 16:49
  • @Syam not working. Can you please test and post your code? Commented Jan 6, 2022 at 16:59
  • 1
    Sure @ASyntuBU , i will add it Commented Jan 6, 2022 at 17:26

1 Answer 1

1

You can use Split() function https://www.w3schools.com/jsref/jsref_split.asp

let splitedResult = xmlhttp.responseText.split("\r"); 

You can assign the values to

element.value = splitedResult[0].trim();
element1.value = splitedResult[1].trim();

Check out this link for the implementation https://jsfiddle.net/SyamKumarD/xa49vspy/29/

I would suggest you to provide a iterable id to your table elements, so you don't need to hardcode the index to your split result and you can iterate through the element and assign the split value dynamically.

Sign up to request clarification or add additional context in comments.

3 Comments

Last couple of values were not separated by space. You might need to split by whitespace or better yet, a new line to be specific instead and then trim. Aside from that, you should be golden.
@Syam I really don't know how to fix last 2 cells or how to add white spaces. Because these values are inside of google published csv file. Even still I have no idea. Thank you for your answer. But if you can properly fix the code, I will accept ur answer. Because I'm still unable to fix the code.
@planpoint, answer's been updated. use \r instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.