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) + '¤tEntityId =' + 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