Ad:
 
Similar Threads
Jul 28th, 2010
0

jQuery Submit Form With Link

Expand Post »
Hi,
I'm having trouble submitting a form using a link. I have a table that lists a bunch of data, and I want to allow users to edit the data directly in the table. The user can click the "EDIT" link, which makes jQuery replace the appropriate <td> html with <input> elements. Then, when the user clicks the "SAVE" link, it should submit the form, but it doesn't.

Table:
HTML Syntax (Toggle Plain Text)
  1. <form id="editSec" action="" method="post">
  2. <table id="listSections">
  3. <tr>
  4. <td>yellow</td>
  5. <td><input type="text" class="First Aisle" value="100" maxlength="3" name="editStart" id="editStart"></td>
  6. <td><input type="text" class="Last Aisle" value="153" maxlength="3" name="editEnd" id="editEnd"></td>
  7. <td><input type="text" class="Hex Code" value="none" maxlength="6" name="editHex" id="editHex"></td>
  8. <td>Yes (<a href="#">toggle</a>)</td>
  9. <td class="colorDemo"><span style="color: pink; background-color: rgb(102, 102, 102); padding: 3px 4px;">YELLOW</span></td>
  10. <td><a class="save" href="#">SAVE</a> | <a class="cancel" href="#">CANCEL</a></td>
  11. </tr>
  12. </table>
  13. </form>

jQuery:
JavaScript Syntax (Toggle Plain Text)
  1. $('a.save', 'table#listSections').live('click', function(event) {
  2. var myRow = $(this).closest('tr');
  3. $("form#editSec").submit(function() {
  4. console.log('form submitted');
  5. $(this).children('input').each(function() {
  6. // do form validations
  7. });
  8. if(!hasError) {
  9. // process form
  10.  
  11. }
  12. });
  13. return false;
  14. });
I placed the "console.log('form submitted');" line there to make sure the form was submitted, but it doesn't show that line in Firebug when I click on the SAVE link. So I think there must be something wrong with how I'm referencing the <form> element, I just can't figure out what it is. If anyone can point out what my mistake is I'd greatly appreciate it.

On a side note, will the $(this) on line 5 of the jQuery reference the form, or a.save ?
Reputation Points: 20
Solved Threads: 26
Junior Poster
EvolutionFallen is offline Offline
152 posts
since Aug 2009
Jul 29th, 2010
0

Re: jQuery Submit Form With Link

*bump*
Anyone have any ideas? I could really use some help with this...
Reputation Points: 20
Solved Threads: 26
Junior Poster
EvolutionFallen is offline Offline
152 posts
since Aug 2009
Jul 29th, 2010
0

Re: jQuery Submit Form With Link

Nevermind, problem fixed.
Reputation Points: 20
Solved Threads: 26
Junior Poster
EvolutionFallen is offline Offline
152 posts
since Aug 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: I want to detect input language of client
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Javascript RSS library





About Us | Contact Us | Advertise | Acceptable Use Policy
Build Custom RSS Feed


Follow us on Twitter


© 2010 DaniWeb® LLC