Save user form input data in a JavaScript object

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • 👉 Source code: openjavascript...
    💬 Like to chat JS/webdev? Say hello on our new community forum: forum.openjava...
    ⚡ Looking for high-performance, afforable web hosting? We use HostWithLove: bit.ly/3V2RM9Q ❤️
    This tutorial shows you how to save user input from a HTML form in a JavaScript object using the native FormData() object constructor. Also covered is how to pass the form data to another page of the form via localStorage.
    #javascript #html #formdata #htmlforms #webdevelopment
    🔔 Subscribe for more tutorials just like this: / @openjavascript
    ⚡ NEW: Web development courses from Meta Inc. ⚡
    Front-End Developer Professional Certificate: imp.i384100.ne...
    Back-End Developer Professional Certificate: imp.i384100.ne...
    iOS Developer Professional Certificate: imp.i384100.ne...
    Meta Android Developer Professional Certificate: imp.i384100.ne...
    Meta Database Engineer Professional Certificate: imp.i384100.ne...
    Website: openjavascript...
    Twitter: / openjavascript

Комментарии • 44

  • @OpenJavaScript
    @OpenJavaScript  Год назад

    Thanks for watching!
    👉 Source code: openjavascript.info/2022/10/03/save-user-form-input-data-in-a-javascript-object/

  • @MantraMantis
    @MantraMantis Год назад +5

    I was stuck on this concept for hours and your tutorial really helped me. Thank you.

    • @OpenJavaScript
      @OpenJavaScript  Год назад

      That's great to hear, glad you found the video useful!

  • @jackepner9984
    @jackepner9984 Год назад +2

    Thanks for the video, but would be amazing if you could tack on a section that is more real-world applicable, where instead of saving the object to local storage, it's passed to a backend server using proper routing. Thank you!

  • @buvaneswari8461
    @buvaneswari8461 Год назад +2

    Thank you so much sir
    You just plunged into the topic

  • @perorbem
    @perorbem Год назад +3

    Thanks so much for this tutorial! I'd been struggling with this for a while, so it helped a ton :)

  • @raven.4815
    @raven.4815 Год назад +1

    Exactly what I was looking for! Thank you so so much!

  • @sh9vch9nk0
    @sh9vch9nk0 5 месяцев назад

    Veryyyy useful, helped me a lot! Thank you for this clear tutorial 💗💗

  • @fakharany
    @fakharany 9 месяцев назад +2

    Thank for the great video, Now I was wondering can I use this method in my website to store contact us form data in a text file (s) to check later for message from web visitors who wishes to communicate with me ?

  • @moyomi8713
    @moyomi8713 Месяц назад

    this helped!

  • @homecookingwithnaturalspic8398
    @homecookingwithnaturalspic8398 Год назад +1

    thanks a lot for this tutorial

    • @OpenJavaScript
      @OpenJavaScript  Год назад

      You're welcome, I'm glad you found it useful!

  • @abunurullah2340
    @abunurullah2340 9 месяцев назад

    Very interesting..........thanks, bro................

  • @SuperNorban
    @SuperNorban Год назад +1

    thanks. hi from argentina!

  • @marcopel83
    @marcopel83 Год назад +2

    This is gold! thanks a lot

  • @ashkanahmadi
    @ashkanahmadi Год назад +1

    Interesting approach thanks. As far as I know, it's not best practice to store any personal information locally in the cookie or local storage.

    • @OpenJavaScript
      @OpenJavaScript  Год назад +1

      Yes, to optimize security it's probably best to send data to the server.
      But another possibility I didn't discuss in the video is to use the same technique but using sessionStorage. This way, the data is immediately deleted when the user leaves your site.

  • @MrBrady95
    @MrBrady95 4 месяца назад

    Awesome, thanks!

  • @mansnotprot1544
    @mansnotprot1544 4 месяца назад

    Thank you so much! :)

  • @viniciusm.m.7822
    @viniciusm.m.7822 Год назад

    Nice explanation, bro!
    Thanks!

  • @oldmanlogan1646
    @oldmanlogan1646 Год назад +1

    awesome content, thx a lot!

  • @alinaeem9016
    @alinaeem9016 Год назад +1

    where are the credentials stored??

  • @walidnazmifordigitization5204
    @walidnazmifordigitization5204 Год назад +1

    Brilliant

  • @qual1481
    @qual1481 Год назад +1

    Hey man great video, just wondering is it possible to do this exact thing but instead of going to a new page i can retrieve it on the same page? Cus im making a single page app with angular and need to do something like this, thanks.

    • @OpenJavaScript
      @OpenJavaScript  Год назад +1

      Sure, you can save the data to localStorage and then retrieve it on the same page.
      This other video I made may be useful for you where I go into more detail on localStorage/sessionStorage: ruclips.net/video/x0VcigW9kN0/видео.html

  • @xtreemz247
    @xtreemz247 Год назад +1

    hi, Great video man. Is it possible to save the data to notepad on disk of the PC?

    • @OpenJavaScript
      @OpenJavaScript  Год назад +1

      Yes, you can start a client-side download of data you hold in JavaScript.
      First, though, you need to get your data inside a blob (a data container). In your case, you'll want to get it in string format first which I'm doing below using JSON.stringify():
      For the downloading of the blob itself, I created a tutorial you can follow to do that: ruclips.net/video/oHGnaE2BQXo/видео.html
      const obj = {prop1: "val", prop2: "val"};
      const json = JSON.stringify(obj, null, 4); // (options add indentation for readability)
      const blob = new Blob([json], {type: "text/plain"});

  • @user-lj2ce5wu6i
    @user-lj2ce5wu6i Год назад +1

    How would you implement this but instead of using local storage, it will be through sqlite

    • @OpenJavaScript
      @OpenJavaScript  Год назад

      Hi Karla, good quesiton, I haven't actually created a tutorial on using SQLite yet but I will keep this problem and topic in mind for a future video.

  • @amitpmit
    @amitpmit Год назад +1

    thank you

  • @larryjasontueno9016
    @larryjasontueno9016 11 месяцев назад

    How does the entries overright what was alreadt there

  • @user-nl3fc6is6b
    @user-nl3fc6is6b Год назад

    can any clear me one thing do we need to link confirm.html or else not

  • @pratibhabade2430
    @pratibhabade2430 Год назад

    can we use any other keywords or properties instead of and ? 6:18

    • @MinusC24
      @MinusC24 25 дней назад

      yeah cus he's just using the tags to display it

  • @lucky_bus
    @lucky_bus 11 месяцев назад

    Shouldn't you be using the 'for' attribute with 'id' of the input, rather than the 'name' . It's strange but you use neither the 'id', nor the 'name', just some random 'for' values.

  • @untrusted0
    @untrusted0 Год назад

    is it possible to edit whats inside the object?

    • @Cuber1771
      @Cuber1771 5 месяцев назад

      Sorry i'm late but yes you can:
      document.getElementByID('ID').innerHTML = "New text";
      You can also edit things like the link, image, or source by changing what's after the dot:
      document.getElementByID('ID').src = "New source";