cookie to retrieve previous filled out form [on hold]

question contest:

I need some code that will save the information that a user fills in, in a form and when they return all the inputs they have filled in previously are filled in for them using a cookie and java script. the form includes a search also that looks up as the person searches for a country.

enter code here
    <form id="ajax-contact" method="post" action="mailer.php">
        <div class="field">
            <label for="name">Name:</label>
            <input type="text" id="name" name="name" required>
        </div>

        <div class="field">
            <label for="email">Email:</label>
            <input type="email" id="email" name="email" required>
        </div>

        <div class="Type">
        <label for="Type">Type of trip:</label>
            <select>
        <option value="" disabled selected>Select your option</option>
        <option value="Fun with friends.">Fun with friends</option>
        <option value="Family">Family</option>
        <option value="Volunteer travel">Volunteer travel</option>
        <option value="Gap year">Gap year</option>
        <option value=" Business Trip">Business trip</option>
        </select>
        </div>

        <div class="Accommodation">
        <label for="Accommodation">Type of accommodation required:</label>
        <select>
        <option value="" disabled selected>Select your option</option>
        <option value="Hotels.">Hotels</option>
        <option value="Self catering">Self catering cottages</option>
        <option value="Bed and Breakfast">Bed and Breakfast</option>
        <option value="Hostels">Hostels</option>
        <option value="Camping and caravanning">Camping and caravanning</option>
        </select>
        </div>

        <label for="Country">Destination:</label>
    <div style="position: relative; height: 80px;" required>
        <input type="text" name="country" id="autocomplete-ajax" style="position: absolute; z-index: 2; background: transparent;"/required>
        <input type="text" name="country" id="autocomplete-ajax-x" disabled="disabled" style="color: #CCC; position: absolute; background: transparent; z-index: 1;"/required>
    </div>
    <div id="selction-ajax"></div>

<script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery.mockjax.js"></script>
<script type="text/javascript" src="src/jquery.autocomplete.js"></script>
<script type="text/javascript" src="scripts/countries.js"></script>
<script type="text/javascript" src="scripts/demo.js"></script>

<div class="CheckInDate">
<label for="CheckInDate">Check in date:</label>
<input type="date" name="CheckInDate" id="CheckInDate"required>
</div>

<div class="CheckOutDate">
<label for="CheckOutDate">Check out date:</label>
<input type="date" name="CheckOutDate" id="CheckOutDate"required>
</div>

            <div class="field">
            <button type="submit">Send</button>
        </div>
    </form>
</div>
`

question comments:

    
1  
“I need some code”. And we need to you go and figure some code out for yourself but come back if it goes wrong and we’ll help you. SO is not a coding service.
    
I agree with the above comments, but you can try and use the new localStorage for javascript
    
With not much googling I found a really good guide on this, it should do the trick. the-art-of-web.com/javascript/setcookie
Tags:

Add a Comment