jquery form submit

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    jquery form submit

    hii guys i am trying to sumit multiple forms in a single page like this.i am trying to alert yes when it come to jquery .but its not printing....plz help on this ?


    Code:
    <head>
    <script src="jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {
         $(".button1").click(function() {  
            $.post("useful.php",{ brand:$("#brand").val(),model:$("model").val(),id:$("#id").val(),check:$("#check").val() } ,function(data){
            alert("yes");
            // $("#change").html(data);
            });
            });     
    });
    </script>
    
    </head>
    <?php
     $sqlreview = "select * from mobile_user_reviews where property1 = '". $brand ."' and property2 = '". $model ."' ";
                    $resultreview = mysql_query($sqlreview);
                    if(mysql_num_rows($resultreview) > 0)
                    {
    
                            $myresult .= "<b>Reviews</b>";
                            $myresult .= "<ul>";
                            $j=1;
                    while($row = mysql_fetch_array($resultreview))
                    {
                            $myresult .= "<li>";
                            $myresult .= "<form name='' method='POST' action =''>";
                            $helpful = gettotalhelp ($row['id']);
                            $helpfulcount = gettotalhelpcount ($row['id']);
                            $myresult .= "<input type='hidden' id='id' name='id' value='".$row['id']."'>";
                            $myresult .= "<input type='hidden' id='model' name='model' value='".$model."'>";
                            $myresult .= "<input type='hidden' id='brand' name='brand' value='".$brand."'>";
                            $myresult .= "$helpfulcount of $helpful people found the following review helpful:<br/> ";
                            $myresult .= getuserrealname($row['userid']).' : '.$row['review'] .' , '.date("dS, F, Y h:i a",$row['reviewedon']);
                            $myresult .= "<br/>";
                            $myresult .= "&nbsp; Was this review helpful to you? &nbsp; <input type ='radio' id='check' name='check' value='Yes'> YES
                                            &nbsp; <input type ='radio' id='check' name='check' value='No'>NO&nbsp;<input type='submit' name='submit' class='button".$j."' value='submit'>";
                            $myresult .= "<br/>";
                            $myresult .= "</form>";
                            $myresult .= "</li>";
                            $j++;
                    }
                            $myresult .= "</ul>";
                    }
            }
    echo $myresult;
    ?>
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Your giving multiple elements the same id, this not only breaks HTML standards but is also the reason why jQuery fails. You'll have to come up with a better solution to your problem.

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      But on submit only 1 id will be active rite so i tht its correct ..can u suggest some solution to this problem ...

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Yes, but what would "#brand", "#change", etc. refer to?

        ...and a suggestion: use unique IDs and pass the number, e.g. brand1, so pass 1 to the function, so that you can access the correct element.

        Comment

        Working...