This has come up a number of times.

My suggestion is to use a "proxy link". When the link is pressed it
"clicks" the button. That way you don't need to modify any of the
backend code, and it will work without JavaScript on.

Something like this:

$(function() {
      $('input.proxy').each( function() {
              var input = $(this);
              $('<a href="#">' + this.value + '</a>')
                      .attr( 'class', this.className )
                      .insertBefore( this)
                      .click( function() {
                              input.click();
                              return false;
                      });
              input.hide();
      });
});

The initial HTML looks like this:

  <input class="proxy" type="submit" value="Save">

After jQuery has done it's thing it look like this:

  <input type="submit" class="proxy" value="Save" style="display:none">
  <a href="#" class="proxy">Save</a>

And voila, you have a link you can style to your heart's content the
functions just like the normal submit button.

Karl Rudd

On 6/9/07, Ken Iovino <[EMAIL PROTECTED]> wrote:

I'm wondering if it's possible to use a text link to submit a form
that has a unique id? I'm using the Official form plug in (http://
www.malsup.com/jquery/form/) which is great, aside from me not being
able to figure this out. (=

Here is the code I'm using

<php start loop>
<script type="text/javascript">
<!--
        $(document).ready(function() {
            $('#deleteForm<?=$comment['commentid']?>').ajaxForm({
                target: '#editor-response',
                success: function() {
                        $("#deletemsg<?=$comment['commentid']?
>").not(".alert").append(msg)
                }
            });
        });
-->
</script>

<form action="ajax/delete_comment.php" method="post" id="deleteForm<?=
$comment['commentid']?>">
        <input type="hidden" name="do" name="deletecomment">
        <a id="#deleteComment<?=$comment['commentid']?>" class="deletlink"
title="Delete this comment?" href="javascript:;">delete?</a>
</form>
</php end loop>

I was using this as the link <a
href="javascript:delete_comment(document.deleteForm<?=
$comment['commentid']?>)"> but it wasn't allowing the form plug-in to
recognize it.

Also, I'm wondering if there a more efficient way to do this.
Currently the JavaScript is inside a php loop and each comment has
it's own unique id. Thanks!


Reply via email to