Похожие чаты

Hello guys! Please help) The task is There are 3 inputs. Output

in textarea the contents of all input fields separated by commas. Use setinterval. (When entering data in the input - they are displayed in the textarea)

The problems is
1. When I just click on the field, 3 commas is appearing, but every comma should appear only after entered text.

2. How to do that the last comma after value didn't appear?

Thank you!

16 ответов

10 просмотров
Anna-Anna Автор вопроса

like if (inputs[i].value != "") { text += inputs[i].value + ', '; }

Hitmare Chelien
like if (inputs[i].value != "") { text += inputs...

If you want to show only on input they why using setinterval just add oninput or onchange event Then just add condition like this one

Anna-Anna Автор вопроса
Anna Anna
Thank you a lot!!!☺️

but Pranav has a point. instead using an interval you could update the big textfield by using onipnput or onchange that way you could eliminate the last comma with ease as well

Anna-Anna Автор вопроса
Hitmare Chelien
but Pranav has a point. instead using an interval ...

I'm still only at the beginning, so here task without events yet. Therefore emulated by setInterval.

Anna-Anna Автор вопроса
Hitmare Chelien
but Pranav has a point. instead using an interval ...

Or I didn't get something?)🤔 About that last comma decided to ask a teacher, maybe let it be there, in case of adding more fields, for example)))😁 Than will not touch it)))

Anna-Anna Автор вопроса
Hitmare Chelien
but Pranav has a point. instead using an interval ...

There should be no comma after the last one. Omg)))😱

Anna Anna
There should be no comma after the last one. Omg))...

thats what i tought ^^' you could to a i'd say rather quick and dirty solution and change if (inputs[i].value != "") { text += inputs[i].value + ', '; } to if (inputs[i].value != "") { text += inputs[i].value; if (inputs.length < i) { text += ', '; } }

Anna Anna
screenshot

can you make a screenshot like this again ?

Anna Anna
screenshot

Array.from(inputs, x => x.value).filter(Boolean).join(', ');

Anna-Anna Автор вопроса
Anna-Anna Автор вопроса
Anna Anna
I'm still only at the beginning, so here task with...

This is a terrible way to teach 🤦‍♂️

Похожие вопросы

Обсуждают сегодня

Вопрос по диагностике ошибок (я знаю в чем, в данном конкретном примере, я знаю, как исправить, пример модельный, понятно, что в реальности бывает намного запутаннее). module...
ⰄⰎⰋⰐⰐⰑⰛⰤⰧⰧⰩⰄ ⰊⰑⰁⰓⰡⰛⰦⰕⰫ
10
Asus, норм фирма для ноутов?
Артем Записной
20
И ещё - определить, имеет ли он доступ к интернету очень просто - смотрим всех пользователей сети. И да, как оно без сети передаст данные в куда то?
BytePixel 🐧
15
А чем вам питонисты не угодили?😂
.
79
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
48
Hey everyone! How can I pass string from Rust to c++ function that expects std::string? When I'm passing CString the c++ functions tell that the string is empty
Jacob
16
Ясн. Но я всеравно к кедам отношусь с опасением. Чисто субьективное кедосозерцание. Что касаемо "восторга изяшности кед" так и не вкурил, хотя много слышал, пока не поставил с...
Артем Записной
30
Hey guys, did you see the new announcement about $Fun? 🔥
Filip Murphy
55
Есть предложения, как подобное можно упростить?
Hemul GM
12
type TObj = object procedure Init; virtual; end; TObj1 = object(TObj) procedure Init; override; end; procedure TObj1.Init; begin inherited; end; procedur...
Alexander 👋
29
Карта сайта