Guys please, i really need your help real urgently. I've search the web times without number but couldnt get anything tangible. I have a php loop like this . 'While($row=mysql_fetch_array($dbquery)){$username=$row['username'];
print("<input type='submit' value='$username'>");}'
now i have a jquery code to select each value contained in the hidden input 'var x=$("input").attr('value');'
! Then value x is sent to a php code via ajax when each button displayed is clicked.
but in my success function in the ajax code, i set it that if there is a success, the value x should be alerted on the webpage. I.e, 'success: function(){alert("" x);}'
but the problem is, instead of the alert to display different usernames in the alert box, its only displaying the first username. Like its not seeing the var x as an array or something. Though thats just a rough code, but i'm sure you guy know what i mean now. Please, help me please

When you post code, please use the Code button up above the text area. It makes it a lot easier to read and keeps the formatting.

Your select the submit like

var x = $("form :submit").attr('value');

Your alert from success should be

success: function(){alert("" + x);}

Actually, you arent getting the point bro. The thing is, how can i make jquery select each value from the loop and give me the different values in the alert box for every different button i click

The PHP is irrelevant, jQuery doesn't care about PHP. Show the markup that is getting output by your loop.

And I get the point. I got the point many years ago ;-)

This is a simple example of how you could do something like you're describing.
http://jsfiddle.net/pixelsoul/ULBNj/

Of course you would need to change the :button to :submit but I'm sure you know that already. You'll have to work it into what ever you have already that is making your AJAX call.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.