Add to shortlist

Add to shortlist

Hi,

Im trying to setup a add to shortlist script and using the following code:

  1. <script>
    function submitForm() {
        $.ajax({type:'POST', url: 'addtoshortlist.php', data:$('#ContactForm').serialize(), success: function(response) {
            $('#ContactForm').find('.form_result_2','.data-postid').html(response);
        $("#form_result2").load("addtoshortlist2.php");
       }});

        return false;

    }
    </script>

//HTML



  1. <form id="ContactForm" onsubmit="return submitForm();">
    <input type="hidden" name="id" value="12344" />

    <a href='view.php?id=12344' class="button1">More Info</a>

    <div class="form_result_2" data-postid="1"> or <input type="submit" value="Save to Shortlist" class="imgClass" /></div>
    </form>

    <form id="ContactForm" onsubmit="return submitForm();">
    <input type="hidden" name="id" value="54555" />

    <a href='view.php?id=54555' class="button1">More Info</a>

    <div class="form_result_2" data-postid="2"> or <input type="submit" value="Save to Shortlist" class="imgClass" /></div>
    </form>

    <form id="ContactForm" onsubmit="return submitForm();">
    <input type="hidden" name="id" value="5545454" />

    <a href='view.php?id=5545454' class="button1">More Info</a>

    <div class="form_result_2" data-postid="3"> or <input type="submit" value="Save to Shortlist" class="imgClass" /></div>
    </form>

Now using just one form i can get it to work fine but when using more than one i cannot so i have placed a data-postid in each div i.e. data-postid=1 data-postid=2 etc,

How can i pass the data-postid value so it only returns to that div and not all of them?