jquery pagination problem

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

    jquery pagination problem

    Code:
    <html>
    <head>
            <script src="jquery.js" type="text/javascript"></script>
            <script src="jquery.rating.js" type="text/javascript" language="javascript"></script>
            <link href="jquery.rating.css" type="text/css" rel="stylesheet"/>
            <link rel="stylesheet" type="text/css" href="style.css">
    
    <script type="text/javascript">
    $(document).ready(function() {
        $("#mobile_brand").change(function() {
                    $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
     $("#change").html(data);
    });
        });
        $("#property3").change(function() {
                    $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
     $("#change").html(data);
    });
        });
        $("#property4").change(function() {
                    $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
     $("#change").html(data);
    });
        });
        $("#property6").change(function() {
                    $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
     $("#change").html(data);
    });
        });
    });
    </script>
    
    </head>
    <body>
    i have a small prob. the jquery.rating.j s does work when the page is loaded but when the filtering takes place with the further jquery statements the 1st jquery.rating.j s which replaces all the checkboxes with the star symbol does not work it displays the checkbox as it it!! i dont know whts the prob.
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi,
    Just place the file inclusion in the end of the body in your html... Like call the function after the page is loaded... This will do.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      what files !! i tried to keep the javascript files at end of body!!! but did not work!!!

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Hi, I dont have much knowledge on JQuery. I have worked in Prototype. Is there any Listener function or observer function for body load, if there just use that and place the script code inside that

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        • pradeepjain
          Contributor
          • Jul 2007
          • 563

          #5
          as u can see in the code
          Code:
          <script type="text/javascript">
          $(document).ready(function() {
              $("#mobile_brand").change(function() {
                          $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
           $("#change").html(data);
          });
              });
              $("#property3").change(function() {
                          $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
           $("#change").html(data);
          });
              });
              $("#property4").change(function() {
                          $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
           $("#change").html(data);
          });
              });
              $("#property6").change(function() {
                          $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
           $("#change").html(data);
          });
              });
          });
          </script>
          is the code where ready body load is taken care of .
          should i use the script code inside here or how?

          Comment

          • RamananKalirajan
            Contributor
            • Mar 2008
            • 608

            #6
            Can you please post the code for this "jquery.rating. js which replaces all the checkboxes with the star symbol". If possible attach the html files and Js Files.

            Thanks and Regards
            Ramanan Kalirajan

            Comment

            • pradeepjain
              Contributor
              • Jul 2007
              • 563

              #7
              you can find the jquery.rating.j s

              jQuery Star Rating Plugin. Contribute to fyneworks/star-rating development by creating an account on GitHub.


              i just name the checkbox class as star and it replaces it with star . if u still want ma code i will paste it.

              Comment

              • RamananKalirajan
                Contributor
                • Mar 2008
                • 608

                #8
                Post Your Code...

                Thanks and Regards
                Ramanan Kalirajan

                Comment

                • pradeepjain
                  Contributor
                  • Jul 2007
                  • 563

                  #9
                  this is a page called product_display .php

                  Code:
                  <?php
                  session_start();
                  include_once('db.php');
                  include_once('valid-scripts/validateData.php');
                  error_reporting (E_ALL & ~ E_NOTICE);
                  ?>
                  <html>
                  <head>
                          <script src="jquery.js" type="text/javascript"></script>
                          <script src="jquery.rating.js" type="text/javascript" language="javascript"></script>
                          <link href="jquery.rating.css" type="text/css" rel="stylesheet"/>
                          <link rel="stylesheet" type="text/css" href="style.css">
                  
                  <script type="text/javascript">
                  $(document).ready(function() {
                      $("#mobile_brand").change(function() {
                                  $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                   $("#change").html(data);
                  });
                      });
                      $("#property3").change(function() {
                                  $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                   $("#change").html(data);
                  });
                      });
                      $("#property4").change(function() {
                                  $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                   $("#change").html(data);
                  });
                      });
                      $("#property6").change(function() {
                                  $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                   $("#change").html(data);
                  });
                      });
                  });
                  </script>
                  
                  </head>
                  <body>
                  <div id="layout">
                  <br/>
                  <?php include_once('menu.php'); ?>
                  <h2>Mobiles</h2>
                  <?php
                  $sql1="select distinct(property1) from mobiles";
                  $result1=mysql_query($sql1);
                  $myresult1 = "";
                  $myresult1 .= "<form name='' method='POST' action=''>";
                  $myresult1 .= "<select name='mobile_brand' id='mobile_brand'>";
                  $myresult1 .= "<option value=''>Mobile Brand</option";
                  while($row1=mysql_fetch_array($result1)){
                  $myresult1 .= "<option value='".$row1['property1']."'>".$row1['property1']."</option";
                  }
                  $myresult1 .= "</select>&nbsp;";
                  
                          $enumFields = getEnumFieldValues('mobiles', 'property4');
                          $myresult1 .=  "<select name='property4' id='property4'>";
                          $myresult1 .= "<option value=''>Price</option";
                           foreach($enumFields as $value)
                                 {
                                    $myresult1 .= '<option value='.$value.'>'.str_replace("'","",$value).'</option>';
                                 }
                          $myresult1 .= "</select>&nbsp;";
                  
                  
                          $enumFields = getEnumFieldValues('mobiles', 'property3');
                          $myresult1 .=  "<select name='property3'id='property3'>";
                          $myresult1 .= "<option value=''>Type</option";
                           foreach($enumFields as $value)
                                 {
                                    $myresult1 .= '<option value='.$value.'>'.str_replace("'","",$value).'</option>';
                                 }
                  $myresult1 .= "</select>&nbsp;";
                  
                          $enumFields = getEnumFieldValues('mobiles', 'property6');
                          $myresult1 .= "<option value=''></option";
                          $myresult1 .=  "<select name='property6' id='property6' >";
                          $myresult1 .= "<option value=''>Os</option";
                           foreach($enumFields as $value)
                                 {
                                    $myresult1 .= '<option value='.$value.'>'.str_replace("'","",$value).'</option>';
                    }
                  $myresult1 .= "</select>";
                  
                  $myresult1 .= "</form>";
                  $myresult ='';
                  $myresult .="<div id='change'>";
                  $myresult .="<table width='100%'>";
                  $sql2 = "select *  from mobile_master";
                  $result2 = mysql_query($sql2);
                  //$myresult .="<tr><td><b>&nbsp;</b></td>";
                  //$myresult .="<td><b>Description</b></td>";
                  //$myresult .="<td><b>Overall Rating</b></td>";
                  //$j = 1;
                  //while ($row2 = mysql_fetch_array($result2)){
                  //if($j <= 1){
                  //$myresult .="<td><b>".$row2['property1_name']."</b></td>";
                  //$myresult .="<td><b>".$row2['property2_name']."</b></td>";
                  //}
                  //$j++;
                  //}
                  $myresult .="</tr>";
                  
                  $myresult .="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
                  $sql="select * from mobiles";
                  $result=mysql_query($sql);
                  $i=0;
                  while($row=mysql_fetch_array($result)){
                  $sqlr="select overall_rating from mobiles where property1='". $row['property1']."' and property2='". $row['property2']."'";
                  $resultr=mysql_query($sqlr);
                  $rating = mysql_fetch_array($resultr);
                  $myresult .="<tr><td><center>";
                  if($row['pic'] != ""){
                  $myresult .= "<a href='mobile_rating.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'><img src='picdisplay.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'</img></a><br/>".$row['property1']."&nbsp;". $row['property2'] ;
                  }
                  else
                  {
                  $myresult .= "<a href='mobile_rating.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'><img src='images/no-image.gif' width='50' height='70'</img></a><br/>".$row['property1']."&nbsp;". $row['property2'];
                  }
                  $myresult .="</center></td>";
                  
                  /*if($row['description'] != ""){
                  $myresult .= "<td>" . $row['description']. "</td>";
                  }
                  else
                  {
                  $myresult .= "<td>&nbsp;</td>";
                  }*/
                  //if($rating['overall_rating'] != ""){
                  $i++;
                  $myresult .= "<td>";
                  for($k = 1; $k <= 10; $k++)
                  {
                  if($rating['overall_rating'] == $k)
                  {
                          $chk ="checked";
                  }
                  else
                  {
                          $chk = "";
                  }
                  $myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."' value='". $k ."' $chk title='". $k." out of 10 ' disabled/>&nbsp;&nbsp;";
                  }
                  $myresult .= "</td>";
                  /*$myresult .= "<td>" . $rating['overall_rating']. "</td>";
                  }
                  else
                  {
                  $myresult .= "<td>&nbsp;</td>";
                  }*/
                  //$myresult .= "<td>" . $row['property1']. "</td>";
                  //$myresult .= "<td>" . $row['property2']. "</td>";
                  $myresult .="</tr>";
                  }
                  $myresult .="</table>";
                  $myresult .="</div>";
                  echo $myresult1;
                  echo "<br/>";
                  echo "<br/>";
                  echo $myresult;
                  ?>
                  <br/>
                  </body>
                  </html>

                  and this is mobile_change.p hp
                  Code:
                  <?php
                  require_once('db.php');
                  include_once('valid-scripts/validateData.php');
                  $_POST=snipExtras($_POST);
                  $mobile_brand=$_POST['brand'];
                  
                  $price=$_POST['price'];
                  
                  $type=$_POST['type'];
                  
                  $os=$_POST['os'];
                  
                  $build_query = "";
                          $add = "";
                          $append = "";
                  if($mobile_brand != "")
                  {
                          $append = "yes";
                          $build_query .= " property1 = '" .$mobile_brand ."'";
                  }
                  if($price != "")
                  {
                          if($append =="yes")
                          {
                          $add = "and";
                          }
                          $append = "yes";
                          $build_query .= " $add property4 = '" .$price ."'";
                  }
                  
                  if($type != "")
                  {
                          if($append =="yes")
                          {
                          $add = "and";
                          }
                          $append = "yes";
                          $build_query .= " $add property3 = '" .$type ."'";
                  }
                  
                  if($os != "")
                  {
                          if($append =="yes")
                    {
                          $add = "and";
                          }
                          $build_query .= " $add property6 = '" .$os ."'";
                  }
                  $myresult ='';
                  $myresult .="<div id='change'>";
                  $myresult .="<table  width='100%'>";
                  $sql2 = "select *  from mobile_master";
                  $result2 = mysql_query($sql2);
                  $myresult .="<tr><td><b>&nbsp;</b></td>";
                  //$myresult .="<td><b>Description</b></td>";
                  //$myresult .="<td><b>Overall Rating</b></td>";
                  //$j = 1;
                  //while ($row2 = mysql_fetch_array($result2)){
                  //if($j <= 1){
                  //$myresult .="<td><b>".$row2['property1_name']."</b></td>";
                  //$myresult .="<td><b>".$row2['property2_name']."</b></td>";
                  //}
                  //$j++;
                  //}
                  $myresult .="</tr>";
                  $myresult .="<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
                  if($build_query != ""){
                  $sql="select * from mobiles where $build_query ";
                  $result=mysql_query($sql);
                  $count = mysql_num_rows($result);
                  
                  if($count > 0){
                  $sql="select * from mobiles where $build_query ";
                  $result=mysql_query($sql);
                  $i=0;
                  while($row=mysql_fetch_array($result)){
                  $sqlr="select overall_rating from mobiles where property1='". $row['property1']."' and property2='". $row['property2']."'";
                  $resultr=mysql_query($sqlr);
                  $rating = mysql_fetch_array($resultr);
                  
                  $myresult .="<tr>";
                  if($row['pic'] != ""){
                  $myresult .= "<td><center><a href='mobile_rating.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'><img src='picdisplay.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'</img></a></center><center>". $row['property1']."&nbsp;".$row['property2'] ."</center></td>";
                  }
                  else
                  {
                  $myresult .= "<td><center><a href='mobile_rating.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'><img src='images/no-image.gif' width='50' height='70'</img></a></center><center>". $row['property1']."&nbsp;".$row['property2'] ."</center></td>";
                  }
                  /*if($row['description'] != ""){
                  $myresult .= "<td>" . $row['description']. "</td>";
                  }
                  else
                  {
                  $myresult .= "<td>&nbsp;</td>";
                  }*/
                  /*if($rating['overall_rating'] != ""){
                  $myresult .= "<td>" . $rating['overall_rating']. "</td>";
                  }
                  else
                  {
                  $myresult .= "<td>&nbsp;</td>";
                  }
                  */
                  $i++;
                  $myresult .= "<td>";
                  for($k = 1; $k <= 10; $k++)
                  {
                  if($rating['overall_rating'] == $k)
                  {
                          $chk ="checked";
                  }
                  else
                  {
                          $chk = "";
                  }
                  $myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."' value='". $k ."' $chk title='". $k." out of 10 ' disabled/>&nbsp;&nbsp;";
                  }
                  $myresult .= "</td>";
                  
                  //$myresult .= "<td>" . $row['property1']. "</td>";
                  //$myresult .= "<td>" . $row['property2']. "</td>";
                  $myresult .="</tr>";
                  }
                  }
                  else if($count == 0 && $build_query != ""){
                  $myresult .= "<tr> <td colspan='5'><p class='message'>Sorry No Product Yet available for Display </p></td></tr>";
                  }
                  
                  }
                  else if($build_query == ""){
                  $sql="select * from mobiles";
                  $result=mysql_query($sql);
                  $i=0;
                  while($row=mysql_fetch_array($result)){
                  $sqlr="select overall_rating from mobiles where property1='". $row['property1']."' and property2='". $row['property2']."'";
                  $resultr=mysql_query($sqlr);
                  $rating = mysql_fetch_array($resultr);
                  
                  
                  $myresult .="<tr>";
                  if($row['pic'] != ""){
                  $myresult .= "<td><center><a href='mobile_rating.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'><img src='picdisplay.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'</img></a></center><center>".$row['property1']."&nbsp;".$row['property2']."</center></td>";
                  }
                  else
                  {
                  $myresult .= "<td><center><a href='mobile_rating.php?brand=". $row['property1'] . "&model=".$row['property2'] . "'><img src='images/no-image.gif' width='50' height='70'</img></a></center><center>". $row['property1']."&nbsp;".$row['property2']."</center></td>";
                  }
                  /*if($row['description'] != ""){
                  $myresult .= "<td>" . $row['description']. "</td>";
                  }
                  else
                  {
                  $myresult .= "<td>&nbsp;</td>";
                  }*/
                  /*if($rating['overall_rating'] != ""){
                  $myresult .= "<td>" . $rating['overall_rating']. "</td>";
                  }
                  else
                  {
                  $myresult .= "<td>&nbsp;</td>";
                       }
                  */
                  $i++;
                  $myresult .= "<td>";
                  for($k = 1; $k <= 10; $k++)
                  {
                  if($rating['overall_rating'] == $k)
                  {
                          $chk ="checked";
                  }
                  else
                  {
                          $chk = "";
                  }
                  $myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."' value='". $k ."' $chk title='". $k." out of 10 ' disabled/>&nbsp;&nbsp;";
                  }
                  $myresult .= "</td>";
                  
                  
                  //$myresult .= "<td>" . $row['property1']. "</td>";
                  //$myresult .= "<td>" . $row['property2']. "</td>";
                  $myresult .="</tr>";
                  }
                  
                  }
                  $myresult .="</table>";
                  $myresult .="</div>";
                  echo $myresult;
                  
                  ?>

                  Comment

                  • pradeepjain
                    Contributor
                    • Jul 2007
                    • 563

                    #10
                    pagination problem when using jquery! help !

                    i am using jquery something like this
                    Code:
                    # <script type="text/javascript">
                    # $(document).ready(function() {
                    #     $("#mobile_brand").change(function() {
                    #                 $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                    #  $("#change").html(data);
                    # });
                    #     });
                    #     $("#property3").change(function() {
                    #                 $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                    #  $("#change").html(data);
                    # });
                    #     });
                    #     $("#property4").change(function() {
                    #                 $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                    #  $("#change").html(data);
                    # });
                    #     });
                    #     $("#property6").change(function() {
                    #                 $.post("mobile_change.php",{ brand:$("#mobile_brand").val(),price:$("#property4").val(),type:$("#property3").val(),os:$("#property6").val() } ,function(data){
                    #  $("#change").html(data);
                    # });
                    #     });
                    # });
                    # </script>
                    #
                    to filter using the drop downs!!!! but when paginations of these filtered values the filtration is going off and it will show the all the values!! how to achieve pagination of filtered values?? or which is the best way to use jquery for this purpose!

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      Haven't looked at your code in detail, but perhaps the problem lies in the fact that you're setting the element with ID "change" to include another element with ID "change".

                      PS. threads merged. Please do not double post.

                      Comment

                      • pradeepjain
                        Contributor
                        • Jul 2007
                        • 563

                        #12
                        the 1st problem was different from the second so posted it again with different name sorry .

                        so how exactly is the way to solve the problem .

                        my need is like .

                        there are 4 dropdowns depending on which the respective entries from DB must be selected . and pagination is also required ..
                        will jquery be helpful for this ?

                        Comment

                        • pradeepjain
                          Contributor
                          • Jul 2007
                          • 563

                          #13
                          i cld solve the pagination problem by using the form $_GET and stuff !! but the original problem which i posted 1st still remains!!can any one plz look at code and help me ??

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            You have the following line:
                            Code:
                             $("#change").html(data);
                            This sets the element "change" to the response of the Ajax request to mobile-change.php.

                            In that PHP file, the response includes this line:
                            Code:
                            $myresult .="<div id='change'>";
                            which means multiple duplicate IDs. Either remove this line or make the ID unique.

                            Comment

                            • pradeepjain
                              Contributor
                              • Jul 2007
                              • 563

                              #15
                              oh okie!! i thought it will replace the element with ID change with the data in mobile_change.p hp ..... so added it ....

                              hey i checked the source code ...the ID "change" is there only 1 time after the jquery has also executed !

                              Comment

                              Working...