passing variable sized form

后端 未结 3 1148
无人及你
无人及你 2021-01-19 17:51

I have a form that is of variable size (length) that is populated from a MySQL db. There are 4 fields that make up the information used to create a button (id, button#, nam

3条回答
  •  一生所求
    2021-01-19 18:20

    What about something like this? http://jsfiddle.net/r0k3t/e6W3Z/ as you can see you can add any number of fields and they will all get dumped into qString.

    $('#yourform').submit(function() {
        var qString = "";
        $('#yourform input[type=text]').each(function() {
           qString += $(this).attr("id") + "=" + $(this).val() + "?";
        });
        console.log(qString);
        return false;
    });
    

    From you question is appears that you can grab the values of the button because you do that elsewhere. Once you are happy with the query string you can use .post as Joe Brown suggested.

提交回复
热议问题