1

I am using the following example code here: http://jsbin.com/ujuse

It uses the jQuery JavaScript Library.

How can I change it so that when you select a tick box, the comma is replaced with a new line instead? I need the text area to display:

one_name

one_name1

one_name2

Not as it does at the moment:

one_name,one_name1,one_name2

If anyone could help that would be brilliant as I have tried to download and edit the jQuery JavaScript Library myself with no success.

1 Answer 1

3

You can use .join(), like this:

$('#t').val(allVals.join('\n'))

You can test it here. What's happening currently is since you're passing in an array to a string property, it's basically calling .toString(), which has the same effect as .join(','), you can use a delimiter of your choice though, like newline in the code above.

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

1 Comment

This is perfect! Thank you very much Nick.

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.