Quiz

  1. Can you explain again why all radio buttons in a group have the same name?

    Sure. It's so that the browser knows what things belong in the group. Consider the following:

    Do you like kittens?

    Do you like puppies?

    try to answer both questions.

    it doesn't work because all four are in the same FORM and have the same NAME, so they are one group, and a radio group can only have one selection.

    Here is the submission handler:

    
        $("form").one().on('submit', (evt) => {
            evt.preventDefault();
            const ans = $("[name=ans]:checked").val();
            console.log({ans});
            if(ans!="yes") { alert("are you a monster?"); }
        });
    
    
  2. I'd like to learn more about how the processing of the form key/value pairs works.

    Do you mean on the back end? Yes, we'll get to that in a couple of weeks.

    In a nutshell, the browser sends the data, the back end framework parses it and puts the name/value pairs into a JS dictionary, and our backend handler pulls out the values it wants using JS dot notation (or, in some cases, square brackets).

    Very much like we can do in the front-end now, with the formDictionary() function.

    The difference is access to the database, which the backend does but the front end doesn't.

  3. None :)

    Great!