exhaler Posted November 15, 2009 Share Posted November 15, 2009 hi, i'm trying to use jquery to delete some data from the database. first the user is presented with a combobox (select box) to choose an option <select id="client_id" name="client_id"> <option value="">Select Client</option> <option value="70">test</option> <option value="69">test2</option> </select> on selection i retrieve the data without refreshing using qjuery ajax functions <script type="text/javascript"> $(document).ready(function() { var checking_html = '<img src="../images/loading.gif" alt="" />Loading...'; $("#client_id").change(function() { $("#modules").html(checking_html); get_modules(); }); $("a.delete_module").live("click", function(event) { $("#message").html('Deleting...'); delete_module(); }); }); // Delete selected module function delete_module(){ // Get the Clien id var module_id = $('#delete_id').val(); //use ajax to run the check $("#message").html(module_id); } // Fetch modules for selected client function get_modules(){ // Get the Client id var client_id = $('#client_id').val(); //use ajax to run the check $.post("get_modules.php", { client_id: client_id, style: 'table' }, function(data){ $("#modules").html(data); }); } </script> what comes up is a table with the results and two links edit and delete delete link: <a href=\"#\" class=\"delete_module\" >Delete/a> <input type=\"hidden\" value=\"$id\" id=\"delete_id\"/> i use the input field to get the id of the module, here is my problem when i click on delete link on any one of them i get the value of the first row Quote Link to comment Share on other sites More sharing options...
trq Posted November 15, 2009 Share Posted November 15, 2009 id's are meant to be unique identifiers. eg; You cannot have more than one id set to 'delete_id'. Quote Link to comment Share on other sites More sharing options...
exhaler Posted November 15, 2009 Author Share Posted November 15, 2009 ok, any suggestion to for getting the id of the row to be deleted?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.