0

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

2
Contributors
4
Replies
19
Views
4 Years
Discussion Span
Last Post by pixelsoul
1

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);}

Edited by pixelsoul

0

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

1

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

Edited by pixelsoul

1

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.

Edited by pixelsoul

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.