What is the optimal way to load form data into a string and then to localStorage?
<p>Is this the optimal way to load form data into a string and then to <code>localStorage</code> ?   </p>

<p>I came up with this on my own, and I am not good in programming. It works, for what I need, but I am not sure if it's a bulletproof code?</p>

<pre><code>&lt;script&gt;
    var sg = document.getElementById("selectedGateway");
    var sd = document.getElementById("selectedDestination");
    var dm = document.getElementById("departureMonth");
    var dd = document.getElementById("departureDay");
    var dy = document.getElementById("departureYear");
    var rm = document.getElementById("returnMonth");
    var rd = document.getElementById("returnDay");
    var ry = document.getElementById("returnYear");
    var ad = document.getElementById("adults");
    var ch = document.getElementById("option2");

    $("#searchRequestForm").submit(function() {
        var string = 'From: ' + sg.value + ' \nTo: ' + sd.value + ' \nDeparture: ' + dm.value + '/' + dd.value + '/' + dy.value + ' \nReturn: ' + rm.value + '/' + rd.value + '/' + ry.value + ' \nNumber of adults: ' + ad.value + ' \nNumber of children: ' + ch.value;
        localStorage.setItem("string", string);
    });
&lt;/script&gt;
</code></pre>
