View Single Post
Old 09-22-2012, 06:31 PM   PM User | #1
d'Anconia
Regular Coder

 
d'Anconia's Avatar
 
Join Date: Jan 2010
Location: Tempe, AZ
Posts: 142
Thanks: 15
Thanked 5 Times in 5 Posts
d'Anconia is an unknown quantity at this point
Updating User Rating - Unexpected Token (Function Call Issue?)

Okay so my problems it that I keep on getting the following error:

Code:
Uncaught SyntaxError: Unexpected token (
I have put the line in question in bold. I have had problems before with defining functions and calling them. Why am I getting this error? I just want to call the newStarRating function at this point with the given parameters. Any help would be appreciated!

Code:
           
    
   U.addEvent(U.$('rating_star_1'), 'mouseover', function(){ newStarRating(1, "yellow_full"); } );
   U.addEvent(U.$('rating_star_2'), 'mouseover', function(){ newStarRating(2, "yellow_full"); } );
   U.addEvent(U.$('rating_star_3'), 'mouseover', function(){ newStarRating(3, "yellow_full"); } );
   U.addEvent(U.$('rating_star_4'), 'mouseover', function(){ newStarRating(4, "yellow_full"); } );
   U.addEvent(U.$('rating_star_5'), 'mouseover', function(){ newStarRating(5, "yellow_full"); } );
   U.addEvent(U.$('rating_star_6'), 'mouseover', function(){ newStarRating(6, "yellow_full"); } );
   U.addEvent(U.$('rating_star_7'), 'mouseover', function(){ newStarRating(7, "yellow_full"); } );
   U.addEvent(U.$('rating_star_8'), 'mouseover', function(){ newStarRating(8, "yellow_full"); } );
   U.addEvent(U.$('rating_star_9'), 'mouseover', function(){ newStarRating(9, "yellow_full"); } );
   U.addEvent(U.$('rating_star_10'), 'mouseover', function(){ newStarRating(10, "yellow_full"); } );
   <?php 
        
   if (mysqli_num_rows($already_reviewed_query_result) == 1) {
            echo "U.addEvent(U.$('star_rating_div'), 'mouseout', function(){ newStarRating(" . $current_user_review_rows['review_score'] .", 'blue'); } );";
        }
        else {
            echo "U.addEvent(U.$('star_rating_div'), 'mouseout', function(){ newStarRating(0, 'yellow_full'); } );";
            echo "/* \$already_reviewed_query is:*" . $already_reviewed_query . "*/";
        }
        mysqli_close($dbc);
    ?>
 
 



function newStarRating(starNumber, color) {
        'use strict';
        var i = null;
        for (var i = 1; i <= 10; i++) {
           document.getElementById('rating_star_' + i).src='../images/white_star_17px.png';
        } //end of star color reset
        
        var j = null;
        for (var j = 1; j <= starNumber; j++) {
            
            document.getElementById('rating_star_' + j).src='../images/' + color + '_star_17px.png';
            
        }
        
    }

function starSubmitFxn(starNumber) {
    'use strict';
    
    //Get a reference (get element by ID) to the entered username value:
    var ajax = getXMLHttpRequestObject();
    
    
    var currentUsername = '<?php echo $current_username ?>';
    var currentEntityId = '<?php echo $entity_id ?>';
    

                ajax.onreadystatechange = function() {
                    if (ajax.readyState == 4){
                        //Check the status code:
                        if ( (ajax.status >= 200 && ajax.status < 300) || (ajax.status == 304) ) {
                            for ( var r = 1; r <= 10; r++){
                                if (ajax.responseText == r) {
                                    newStarRating(r, "blue");//end of newStarRating call
                                    } //end of response text check
                                } //end of loop
                        
                            } //end of Ajax connectivity check
                        } //end of Ajax ready state
                    }; //end of function for execution on ready state change
                    
                var data = 'currentUsername=' + encodeURIComponent(currentUsername) + '&currentEntityId =' + encodeURIComponent(currentEntityId)
                            + '&starNumber =' encoreURIComponent(starNumber);
                ajax.open('POST', 'resources/star_submit.php?' + data, true);
                ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

                ajax.send(data);
    }//End of verifyUsername() function
__________________
Powerful ideas for all lovers of personal and political freedom:
Freedomain Radio
Free Talk Live
d'Anconia is offline   Reply With Quote