Search code examples
phpjavascriptjqueryinvoiceaccounts

Find all textbox values and post into PHP MySQL


I am just a newbie to jQuery can some one help me?

I want to create a invoice system like this one

All I need to do is add a submit button that will function some thing like this

.find all input of textareas identified by some unique id

then post that values into php MySQl earch row will contain unqiue data.


Solution

  • Ambiguity in your question anyway this will get you an array of values of all the text boxes

            $(document).ready(function(){
    $('#somebuttonid').click(function(){
            var tbarray = new Array();
            $('.yourtextboxclass').each(function(){
            tbarray.push($(this).val()); //You will have a array tbarray with all the values of textboxes
            }):
            $('#somehiddenelementid').val(tbarray);
            $('#somehiddenelementidcontainingform').submit(); //Make sure your action is set,you can access like $_post['$somehiddenelmentname'];
            });
    });
    
        <!--html side-->
        <form id="somehiddenelementidcontainingform" action="youraction" method="post">
        <input type="hidden" name="somehiddenelmentname[]" id="somehiddenelementid" />
        </form>