Question

How can I save values from form to sessionStorage when the form is submitted?

Something like this?

        <form id="myForm" method="get" action="lista.html" rel="external" data-ajax="false" >

        <label for="autonumero"> Anna autonumero </label>
        <input type='tel' name="autonumero" data-corners="false"/>


        <input type="submit" onclick="saveData()" value="OK" data-theme="a" data-corners="false" />



        <script> function savedata()
{ var input = document.getElementById("autonumero");
sessionStorage.setItem("autonumero", input.value); 
</script> 






        </form>

The form needs to be submitted also so just saving the values isn't enough

Was it helpful?

Solution

Try:

<input type="submit" onclick="return saveData();" value="OK" data-theme="a" data-corners="false" />
<script type="text/javascript"> 
function savedata() { 
  var input = document.getElementById("autonumero");
  sessionStorage.setItem("autonumero", input.value);
  return true;
} 
</script> 

OTHER TIPS

try set input id id="autonumero"

<input id="autonumero" type="submit" onclick="return saveData();" value="OK" data-theme="a" data-corners="false" />

Set id="autonumero" to the input field:

<input type='tel' id="autonumero" name="autonumero" data-corners="false"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top