javascript - Find all Form Values and Submit -
All the fields in this form are to be searched and submit them to a PHP page which will be included in mysql, but all I go back an empty array, what's missing here? I do not need a .val ()
& lt; Form id = "form" & gt; & Lt; Table width = "100%" & gt; & Lt; Tbody & gt; & Lt; Tr & gt; & Lt; Th & gt; The display name & lt; / Th & gt; & Lt; Th & gt; Url & lt; / Th & gt; & Lt; Th & gt; Guardian & lt; / Th & gt; & Lt; Th & gt; Ordered order & lt; / Th & gt; & Lt; Th & gt; Active & lt; / Th & gt; & Lt; / TR & gt; & Lt; Tr class = "even" & gt; & Lt; Td width = "200" & gt; Setting & lt; / Td> & Lt; Input type = "hidden" value = "1" id = "setting [0]" & gt; & Lt; Td> & Lt; Input type = "textbox" value = "settings.php" size = "75" id = "settings [1]" & gt; & Lt; / Td> & Lt; Td> & Lt; Select ID = "Settings [2]" gt; & Gt; Option selected = "" value = "0" & gt; No parent & lt; / Option & gt; & Lt; Option value = "1" & gt; Setting & lt; / Option & gt; & Lt; Option value = "2" & gt; Grid demo & lt; / Option & gt; Option value = "3" & gt; Test & lt; / Option & gt; & Lt; Option value = "4" & gt; Grid option & lt; / Option & gt; & Lt; Option value = "5" & gt; Setgred option & lt; / Option & gt; & Lt; Option value = "6" & gt; Menu item & lt; / Option & gt; & Lt; Option value = "7" & gt; Ajax menu & lt; / Option & gt; & Lt; / Select & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text box" value = "0" size = "5" id = "setting [3]" & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "hidden" value = "INACTIVE" id = "settings [4]" & gt; & Lt; Input type = "checkbox" value = "active" id = "setting [4]" & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; Tr class = "odd" & gt; & Lt; Td width = "200" & gt; Grid demo & lt; / Td> & Lt; Input type = "hidden" value = "2" id = "Grid_Demo [0]" & gt; & Lt; Td> & Lt; Input type = "textbox" value = "grid.php" size = "75" id = "Grid_Demo [1]" & gt; & Lt; / Td> & Lt; TD & gt; & Lt; ID = "Grid_Demo [2]" option "=" "value =" 0 "& gt; A parent
option value =" 1 "& gt; Settings & lt; / Option & gt; Option value = "2"> Grid demo Option value = "3"> Test Input & Lt; Div class = "contentarea2" & gt; & Lt; / Div & gt; & Lt; Script & gt; $ ("#Forms"). Submit (function (e) {console.log (click 'click'); e.preventDefault (); var $ form = $ (this); var $ inputs = $ form.find ("Input, select , Button, textera "); var postdata = $ form.serialize (); request = $ .ajax ({url:" saveform.php ", type:" POST ", data: postdata}) .Done (function, Text position, jqXHR) {// return some console.log ('submit');} return that & lt; div & gt; function (data) {$ (".contentarea2"). Html data) ;}, "html") .file (function (jqhxr, textstatus, errorThrown) {console.error ('error:' + textstats, error T);});}); & Lt; / Script & gt;
It says:
Only "successful control" is sorted into the string ... to include the value of a form element in the serialized string element should have the name attribute. Your form elements do not have name = "something" attribute, give them a name and they will be submitted. Note that you do not need the $ inputs variable (which you do not currently use after setting it). postData = $ form.serialize () Once you give the names of your elements.
Comments
Post a Comment