javascript - Difficulty serializing dropdown menu -


basically have number of forms on page , i'd able access them @ once , add them 1 large request. it's largely working, i'm having trouble getting working drop down menus since markup different other forms (at least in examples i've seen). please bear me since i'm new front-end development, i've got far:

    <form id="sorting" class="auto-submit" action="/search" method="get">         <select id="sorting" class="parameter" action="/search" method="get">             % if previous.get("sorting", "false") == "relevance":                 <option selected="selected" name="sort" value="relevance">relevance</option>                 <option name="sort" value="alphabetical">alphabetical</option>             % elif previous.get("sorting", "false") == "alphabetical":                 <option name="sort" value="relevance">relevance</option>                 <option name="sort" selected="selected" value="alphabetical">alphabetical</option>             % else:                 <option name="sort" value="relevance">relevance</option>                 <option name="sort" value="alphabetical">alphabetical</option>             % endif         </select>     </form> 

the script i'm using try access these values (launched elsewhere, don't think that's issue):

function submitforms(retain_page) {     var get_data = [];     var form_list = $(".auto-submit .parameter");     (var in form_list){         get_data.push.apply(get_data, form_list.eq(i).serializearray());     }     var url = document.url.split("?")[0]+"?";     (var o in get_data){         if (retain_page === false){             if (get_data[o].name == "page"){                 get_data[o].value = 1;             }         }         url = url + (get_data[o].name + "=" +get_data[o].value + "&");     }     document.location.href = url.substring(0, url.length-1); } 

i'm pretty issue in how i'm accessing element, , in javascript console able looking running following:

$(".auto-submit .parameter").eq(4).val() 

and when try serializing same element empty response makes me think somehow isn't realizing should submitted in form, i'm kind of @ loss should define it. sorry if silly question, appreciated.

so, figured out how serialize this, assume indicative of deeper problems in coding style won't accept time , totally open other answers.

when gave select element name worked. reference here's updated code:

 <form id="sorting" class="auto-submit" action="/search" method="get">         <select name="sort" id="sorting" class="parameter" action="/search" method="get">             % if previous.get("sort", "false") == "relevance":                 <option selected="selected" value="relevance">relevance</option>                 <option value="alphabetical">alphabetical</option>             % elif previous.get("sort", "false") == "alphabetical":                 <option value="relevance">relevance</option>                 <option selected="selected" value="alphabetical">alphabetical</option>             % else:                 <option value="relevance">relevance</option>                 <option value="alphabetical">alphabetical</option>             % endif         </select>     </form> 

Comments