document.getElementById("button540").onclick = myFunction540;
function myFunction540() {
const phone = document.getElementById("phone540").value;
if (!phone) {
alert("заполните phone");
return false;
}
_rc("send", "order", {
orderMethod: "one-click",
name: document.getElementById("name540").value,
phone
});
}
let data = new FormData();
data.append('file', input.files[0]);
const options = {
method: 'POST',
body: data
}
const response = await fetch('url', options);
const res = await response.json();
console.log(res);
const json = `[{"id":124124,"firstname":"Районный","lastname":"Прокурор","warns":0,"role":11,"flip":0,"rank":"Участник","ban":false,"isBanned":"Нет","tempban":0,"mute":0,"mutesleft":0,"violations":0,"botmute":0,"nick":"хай"},{"id":123123,"firstname":"Кто","lastname":"Никто","warns":0,"role":11,"flip":0,"rank":"Участник","ban":false,"isBanned":"Нет","tempban":0,"mute":0,"mutesleft":0,"violations":0,"botmute":0,"nick":"пока"},{"id":125125,"firstname":"Крутой","lastname":"Поц","warns":0,"role":1,"flip":0,"rank":"Участник","ban":false,"isBanned":"Нет","tempban":0,"mute":0,"mutesleft":0,"violations":0,"nick":"привет"}]`;
const data = JSON.parse(json);
function findNick(arr, nick) {
const res = arr.find(i => i.nick == nick);
if (res) return;
return arr;
}
console.log(findNick(data, 'хай'));
<script>
function changeIMG(){
var pattern=/id=(.+)/g;
var ans=pattern.exec(location.href);
if (ans[1]=='lyubov')
document.getElementById('img2change').src = 'картинка1';
if (ans[1]=='morkov')
document.getElementById('img2change').src = 'картинка2';
}
document.addEventListener("DOMContentLoaded", changeIMG)
</script>
const myMath = {
minNum(...num) {
if (!num.length) {
return console.log(`введите данные`);
}
num = num.filter(num => !isNaN(num - parseFloat(num)));
if (!num.length) {
return console.log(`введите пжл число`);
}
let min = num[0];
for (let i = 1; i < num.length; i++) {
if (num[i] < min) {
min = num[i];
}
}
console.log(`минимальное число ${min}`);
}
}
myMath.minNum('1', 2, -1); // минимальное число -1
myMath.minNum('строка'); // введите пжл число
myMath.minNum(); // введите данные
for (let i = 0; i < dataExample.length; i++) {
document.body.insertAdjacentHTML('beforeend', dataExample[i].company + '<br>');
document.body.insertAdjacentHTML('beforeend', dataExample[i].chef + '<br>');
document.body.insertAdjacentHTML('beforeend', dataExample[i].country + '<br>');
}
function date_time() {
return new Intl.DateTimeFormat('en', {
hour12: false,
day: 'numeric',
month: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZone: 'Europe/Moscow'
}).format(Date.now())
}
date_time(); // "12/29/2020, 08:03:23"
date_time().replace(',', ' Ortszeit:');// "12/29/2020 Ortszeit: 08:03:23"
<div class="utm"><?= isset($_GET['utm_content']) ? $_GET['utm_content'] : '' ?></div>
history.pushState(null, null, location.href.replace('#', ''));
document.querySelector('.close').addEventListener('click', event => event.preventDefault());
["5", "0", "1jj" ].filter(v => !isNaN(parseFloat(v)));
//["5", "0", "1jj1"]
["5", "0", "1jj1" ].filter(num => !isNaN(num - parseFloat(num)));
//["5", "0"]
["5", "0", "jj1" ].filter(Number);
//["5"]
const statuses_default = {
"Logon": {
"order": 1,
"data": {}
},
"Ready": {
"order": 3,
"data": {}
},
"Not Ready": {
"order": 2,
"data": {}
},
"Logoff": {
"order": 0,
"data": {}
}
}
let res = Object.entries(statuses_default).sort((a, b) => a[1].order - b[1].order);
console.log(res)
<form>
<input id="product_preview183" name="variant" value="183" type="radio" class="sytle-input" checked="">
<input class="amounts incr__val" name="add_variant[107]" type="text" value="0">
<input class="amounts incr__val" name="add_variant[108]" type="text" value="2">
<button type="submit" value="">Добавить</button>
</form>
let form = $('form');
let data = form.serializeArray().filter(item => +item.value);//фильтрация подойдет если в value будут цифры, иначе поменять нужно условие
console.log(data );
/*
[
{name: "variant", value: "183"},
{name: "add_variant[108]", value: "2"}
]
*/
// после data передаем в аякс