941,524 Members | Top Members by Rank

Ad:
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 ?
Similar Threads
Reputation Points: 40
Solved Threads: 31
Junior Poster
EvolutionFallen is offline Offline
198 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: 40
Solved Threads: 31
Junior Poster
EvolutionFallen is offline Offline
198 posts
since Aug 2009
Jul 29th, 2010
0
Re: jQuery Submit Form With Link
Nevermind, problem fixed.
Reputation Points: 40
Solved Threads: 31
Junior Poster
EvolutionFallen is offline Offline
198 posts
since Aug 2009
Feb 14th, 2011
0
Re: jQuery Submit Form With Link
can you tell us how you fixed that problem?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
severman is offline Offline
70 posts
since Mar 2008

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.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: sample code for form validation using ajax
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Get value chosen from select, display the value of the array with that same name.





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


Follow us on Twitter


© 2011 DaniWeb® LLC