Store a session on form submit

How can i get a specific element during form submit and store it in a session variable? Say I want to just get the ID of the form with the name = "id". Say the name of the input field was "id"

My form is submitting perfectly to the database but I want to save the ID session variable for later on another page.

i tried

$(‘#form').submit(function(e) {
var inputId =    $('#form :id');
sessionStorage.SessionName = inputId;


var fd = new FormData(document.getElementById(“#form"));

fd.append("label","WEBUPLOAD");



     $.ajax({



    type: "POST",

            url: “myUrl",

            data: fd,



        success: function(data){

        alert(data);

    }



 });

Should I maybe serialize it?


you can use browser session api

sessionStorage.setItem('key','value');

to get id of an element, you can use attr, $("form[name='id']").attr('id').

you can refer to for more ways, How can I get the ID of an element using jQuery?

链接地址: http://www.djcxy.com/p/83308.html

上一篇: 引用div的id

下一篇: 在表单提交中存储会话