JSFiddle - React, Tailwind, and code Playground

by ian_smithz

HTML

<h1></h1>
	 
    <form>
      <fieldset>
        <legend>Survey</legend>
			<div id="boxalign">
				<p>
					<label>Hospital:</label>
					<input name="hospital" type="text" />
				</p>
				<p>
					<label>Name:</label> <input name="hosName" type="text"/>
				</p>
				<p>
					<label>Title:</label><input name="hosTitle" type="text"/>
				</p>
				<p>
					<label>Department:</label> <input name="hosDept" type="text"/>
				</p>
			</div>
		
			<div id="boxalign2">
				<p>
				  
				  <label>Preferred Contact:</label>
					<select id = "myList" name="preferredContact">
						<option value = "1">Email</option>
						<option value = "2">Phone</option>
					</select>
				</p>
                </div>
				
		<label for="serveri"> Server: </label> <input type='text' name="server" id="saveServer"/> <button type="submit" value="Save" id="Save">Save</button>

      </fieldset>
    </form>

JavaScript

$('form').submit(function() {
     $('input, select, textarea').each(function() {
       var value = $(this).val(),
           name = $(this).attr('name');
       localStorage[name] = value;
         
         console.log('stored key: '+name+' stored value: '+value);
    });   
});