First, since all of your functions do the same thing, you do not have to repeat yourself. I would suggest either wrapping all the buttons and textboxes in another element or giving them a class so that they can be selected together, for example:
$('#wrapper input').click(...); or $('.buttonClass').click(...); Next, you say you want the values in an array, but you're currently using separate variables (a, b, and c). Would you have the array predefined or do you want to return an array? Also, if the textboxes appear in the same order that you want to store the values, you can use the .each() method with the enumerator for the array index. For example: $('.buttonClass').click(function() { $('.textboxClass').each(function(i) { MyArray[i] = $(this).val(); }) }); Or something like that, depending on where your array is, whether the elements are in order, whether the number of textboxes is constant, etc. etc. Larry On Dec 26, 1:13 am, phpcurious <[EMAIL PROTECTED]> wrote: > I wanted to create a function that will return an array consisting > values from 3 textboxes. > > let's say: > > $('document').ready(function() { > > $('input#button_a').click(function() { > a = $('input#input_text_a').val(); > b = $('input#input_text_b').val(); > c = $('input#input_text_c').val(); > }); > > $('input#button_b').click(function() { > a = $('input#input_text_a').val(); > b = $('input#input_text_b').val(); > c = $('input#input_text_c').val(); > }); > $('input#button_c').click(function() { > a = $('input#input_text_a').val(); > b = $('input#input_text_b').val(); > c = $('input#input_text_c').val(); > }); > > }); > > is there a way I can create the function within this jquery script? or > is there a workaround? > please teach me, I am new in this aspect. thank you in advance!