Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
Intentando agregar al archivo CSV usando JS

Soy un completo principiante en JavaScript y otras tecnologías web y actualmente estoy tratando de agregar los datos que el usuario ingresa en el formulario de entrada a un archivo CSV.

Esto es lo que he probado hasta ahora:

 <form id="form"> Type the latitude of the crime: <input type="text" name="latitude"><br> Type the longitude of the crime: <input type="text" name="latitude"><br> Enter the date in which the incident took place: <input type="text" name="latitude"><br> <input type="button" value="submit" id="submit-btn" onclick="submitCrime"> </form> <script> //Clear form once submitted function clearForm(){ document.getElementById("form").reset(); } function submitCrime() { var formData = $("form").serializeArray(); let csv = "data:/Users/duvalbalogun-palmer/Desktop/VGIS/php-shit/assault.csv;charset=utf-8,"; // accept data as CSV formData.forEach(function(item) { csv += item.value + ";"; // concat form value on csv var and add ; to create columns (you can change to , if want) }); var encodedUri = encodeURI(csv); clearForm(); </script> </body> </head>

Siempre que haga clic en el botón "enviar", no sucede nada. ¡Cualquier ayuda sería muy apreciada!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Tienes varias cosas sucediendo aquí

<formulario id="formulario">

Está publicando datos sobre delitos, por lo que el formulario debe tener el atributo method="form"' If what you posted isn't a part of a larger servlet / php / aspx file where you are handling the form submission, you should set the acción` atributo en su formulario.

 Type the latitude of the crime: <input type="text" name="latitude"><br> Type the longitude of the crime: <input type="text" name="latitude"><br> Enter the date in which the incident took place: <input type="text" name="latitude"><br> <input type="button" value="submit" id="submit-btn" onclick="submitCrime"> </form>

Debe cambiar el atributo de name en longitud y fecha. Además, mientras lo hace, cambie el tipo a number y establezca los valores mínimo y máximo para la latitud y la longitud, y la fecha debe ser tipo = date

Y en cuanto a su función submitCrime, debe llamar a return true al final o los datos no se enviarán.

 <script> //Clear form once submitted function clearForm(){ document.getElementById("form").reset(); } function submitCrime() { var formData = $("form").serializeArray(); let csv = "data:/Users/duvalbalogun-palmer/Desktop/VGIS/php-shit/assault.csv;charset=utf-8,"; // accept data as CSV formData.forEach(function(item) { csv += item.value + ";"; // concat form value on csv var and add ; to create columns (you can change to , if want) }); var encodedUri = encodeURI(csv); clearForm(); </script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda