Home > Mobile >  Can't get values from datalist in js
Can't get values from datalist in js

Time:05-25

I am trying to get values out of a datalist form but it seems that there's a bug in my script for my 'input#date' and my 'input#idPosition'

Console says :

{person: 'Etudiant', idPosition: input#idPosition, fact: 'Harcèlement', loc: "Dans l'établissement", date: input#date, …} anon: "Oui" date: input#date fact: "Harcèlement" idPosition: input#idPosition loc: "Dans l'établissement" msg: null person: "Etudiant" [[Prototype]]: Object

Could you help ?

CodePudding user response:

nope, those are the right ones const stalkingForm = document.querySelector('#stalkingForm');

stalkingForm.addEventListener('submit', addForm);

function addForm(e) {
    e.preventDefault();
    const formData = new FormData(stalkingForm);
    const person = formData.get('person');
    const position = formData.get('idPosition');
    const fact = formData.get('fact');
    const loc = formData.get('loc');
    const name = formData.get('date');
    const msg = formData.get('msg');
    const anon = formData.get('anon');
    console.log('form', {person, idPosition, fact, loc, date, msg, anon});
    e.return 
}

CodePudding user response:

there is no error report, only i can't get the value out of this input cause it shows 'date: input#date' instead of the value inside it ..

  • Related