0

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?

user6535413
  • 105
  • 7

1 Answers1

0

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?

Community
  • 1
  • 1
user669789
  • 554
  • 4
  • 10
  • 23