1

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.

mac
  • 42,153
  • 26
  • 121
  • 131
Amanullah
  • 81
  • 2
  • 10

2 Answers2

0

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>
coolguy
  • 7,866
  • 9
  • 45
  • 71
0

I was surprised to find that this function, phrased in this way, did not bring back plenty of posts with obvious answers.

Amanullah, a lot of the comments asks that you try for yourself first, because people normally do not like to answer questions that are google'able.

I was going to recommend the same, but when I did a search with your keywords, there were no obvious answers.

To serialize all your input elements, you can use:

$('form :input').serialize() // creates a query string tb1=bob&tb2=smith

$('form :input').serializeArray() // creates a JSON object [{name:"tb1", value:"bob}, {name:"tb2", value:"smith"}]

Note that those go by element NAME and not ID. Once your values are serialized, you can send them to the server. If you only want to grab textboxes, change your selector to $('form :input:text')

rkw
  • 7,287
  • 4
  • 26
  • 39