I know you can’t give a same id to elements in one page. But i have a list which PHP generates with a SELECT * statemnt, this list shows all the rows in database in a HTML table
each row of data has a radiobox next to it which its value is the id of that row in mysql. what I am trying to do here is when you check the Radio for that row and run the Func, JavaScript gets the Value which is the id number so I can delete that row
Something like this: but again I can’t give all the radio the same id
var age = document.getElementById('radio').value;
var queryString = "?id=" + radio;
ajaxRequest.open("GET", "coderemove.php" + queryString, true);
ajaxRequest.send(null);
When I run this nothing happens, obviously
You could use the pure JavaScript approach – imagine the PHP code outputs this:
Then our JavaScript code could be:
But if we use jQuery – then it becomes much simpler:
If you don’t know JavaScript, and you are looking to program web-pages using it, I encourage you to spend an hour learning the basics of jQuery. It will save you some hassle : )