I want to make a table in which in each cell there will be a drawn java script, but it turns out - script by table, how can I fix this?

<html> <head> <title>Stars test</title> <script src='http://jquery-star-rating-plugin.googlecode.com/svn/trunk/jquery.js' type="text/javascript"></script> <link rel="stylesheet" href="rater.css" type="text/css" media="screen" /> <script type='text/javascript' src='jquery.rater.packed.js'></script> <script type='text/javascript' src='jquery.rater.js'></script> </head> <body> <p>Down stars</p> <table border="2" bordercolor="red"> <tr> <td> <div id='rating1' class='rating'> <script type="text/javascript" language="javascript"> $('#rating1').rater('ratings.php', {maxvalue:30, style: 'basic', curvalue:5} ); </script> </div> </td> <td> <div id='rating1' class='rating'> <script type="text/javascript" language="javascript"> $('#rating1').rater('ratings.php', {maxvalue:30, style: 'basic', curvalue:5} ); </script> </div> </td> <td> <div id='rating1' class='rating'> <script type="text/javascript" language="javascript"> $('#rating1').rater('ratings.php', {maxvalue:30, style: 'basic', curvalue:5} ); </script> </div> </td> </tr><tr> <td> <div id='rating1' class='rating'> <script type="text/javascript" language="javascript"> $('#rating1').rater('ratings.php', {maxvalue:30, style: 'basic', curvalue:5} ); </script> </div> </td> <td> <div id='rating1' class='rating'> <script type="text/javascript" language="javascript"> $('#rating1').rater('ratings.php', {maxvalue:30, style: 'basic', curvalue:5} ); </script> </div> </td> </tr> </table> </body> </html> 
  • Or all copies of one script in one cell. - Gorets
  • What does rendered javascript mean? - Anton Mukhin
  • Well, there is a plugin - voting for a picture, pictures in the table, under each picture this script should be displayed, and it is displayed the necessary number of times, but everything is in the first cell. - Gorets
  • Nothing is clear, an example in the studio - neoascetic
  • Somehow, we have a table, in table 3, a cell, it is necessary - in each cell according to the display script. It turns out - all 3 scripts, BUT in 1 cell. - Gorets 1:59 pm

1 answer 1

What is your approach curve. If this problem is solved by your method, then, for example, if there are 100 pictures on a page, you get 100 pieces of code, which is not very useful. Wouldn't it have been easier to do this:

  • Let each picture have its own unique name id
  • Create one handler that determines which image was clicked, i.e. gets her name
  • Then the PHP script needs to transfer this name, where the vote count for the picture with this name increases.
  • Make the necessary changes in the database
  • I understand this logic. Here I just sit playing with ccc and a script, see how it works, but my task is to display the result. Suppose I need to display only 3 pictures on the page, pictures in the table, in each cell under the picture it is necessary to bring this voting system. How to do it? - Gorets
  • This question - Do you have the results of the voting stored? In the database? Or not stored at all? - ikot
  • will be by means of adjax is stored in the database, in my "sandbox", what I laid out, not where it is not stored, I have a problem with the display - Gorets