Jump to content

Need help with Ajax function


bwana

Recommended Posts

Hello all,I need help, with I think Ajax function aka assinchrone call I have table in page with following config: ...link - button1 - button2link - button1 - button2link - button1 - button2.... where button1 is serve for hiding row, and button2 is for voting(here I( need help) and hiding row.Table is formed by function which calls db, pick-up id and links from db rows it and form that table.Id is used for specifying id of 2nd button, so it can be target correctly.It look like this: .... <tr> <td><p>Link 1</p></td> <td><button class="live">live</button></td> <td><button class="add" id="1">add</button></td> </tr> <tr> <td><p>Link 2</p></td> <td><button class="live">live</button></td> <td><button class="add" id="2">add</button></td> </tr>.... What I need is when someone clicks on button to happen:- when they click on "live" button, just to hide that entire row- when they click on "add" button, to add +1 to that link , which id in db is same as id of button, and then to hide that rowAl that I want to happen without reloading page until we have links. Then visitor will manualy reload page. This is format of simple db:id - link - adds I understand that I have to send id if button to another page that will do processing in db(adding +1 on adds field), but I dont know how. I tried on few forums, but didn't had success so far. You are my last chance.

Link to comment
Share on other sites

Start by putting an onclick handler on each button so that you can run some code when you click on the button. You should pass this to each of the onclick handlers, which will be set to a reference to the button. That means that inside the click handler you know which button was clicked, so you can go up in the DOM until you find the tr you want to hide, and hide it. You can also get the ID of the button and send that to PHP via ajax.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...