My question is can I change this code using variables and use conditionals and how can I do it? My problem is The Validation I need that it is only necessary to fill in only one piece of information and it is not necessary to fill out the entire form
<script>
function save_producto(){
let fd=new FormData();
these are the values I want to pass to variables
fd.append('arriba',document.getElementById('arriba').value);
fd.append('abajo',document.getElementById('abajo').value);
fd.append('imagen',document.getElementById('imagen').files[0]);
This the part show the errors
request.open('POST','api/producto_save.php',true);
request.onload=function(){
if (request.readyState== 4 && request.status== 200) {
let response= JSON.parse(request.responseText);
console.log(response);
if(response.state){
alert("correcto");
}else{
alert(response.detail);
}
}
}
send everything
request.send(fd);
}
</script>