Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6113429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:51:29+00:00 2026-05-23T14:51:29+00:00

I have this Star Rating system right. When you click on a star it

  • 0

I have this Star Rating system right. When you click on a star it should pass a value into the function. Then using AJAX it posts it to an external PHP file. The only problem is that when it gets to the PHP file it comes as null or no value.

I will try to echo the $_POST[‘vote’] variable in an alert box using AJAX and it is blank so it doesn’t come back as “NULL” or “0” it’s just nothing. I’m not sure where I’m losing the value because I can track it all the way to the send() function. Anyone see a problem?

HTML:

<style type="text/css">
    #container{margin: 10px auto;width: 500px;height: 300px;background-color: gray;}
    #starContainer{padding-top:20px;margin:0 auto;width:150px;}
    .box{height:28px;width:30px;float:left;position:relative;z-index:5;cursor:pointer;}
    .star{background-image:url('emptyStar.png');background-repeat:no-repeat;}
    .starHover{background-image:url('goldStar.png');background-repeat:no-repeat;}
    #voteBar{float:left;height:28px;background-color:#dbd923;position:relative;top:-28px;z-index:1;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('.box').hover(
        // Handles the mouseover
        function() {
            $(this).prevAll().andSelf().addClass('starHover');
        },
        // Handles the mouseout
        function() {
            $(this).prevAll().andSelf().removeClass('starHover'); 
        }
    );
});

    function Cast(vote)
    {
        if(window.XMLHttpRequest)
        {
            xmlhttp = new XMLHttpRequest();
        }
        else
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange = function()
        {
            if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                alert(xmlhttp.responseText);
                var json = JSON.parse(xmlhttp.responseText);
            }
        }

        xmlhttp.open("POST", "process.php", true);
        xmlhttp.send('vote=' + vote);
    }
</script>

</head>
<body>

<div id="container">
    <center>
        <div id="starContainer">
            <div class="box star" onclick="Cast(1)"></div>
            <div class="box star" onclick="Cast(2)"></div>
            <div class="box star" onclick="Cast(3)"></div>
            <div class="box star" onclick="Cast(4)"></div>
            <div class="box star" onclick="Cast(5)"></div>
            <div id="voteBar"></div>
        </div>
    </center>
</div>

</body>
</html>

PHP:

<?php
$vote = $_POST['vote'];

$totalVoteValue = 0;
$amtVotes = 1;

$width = (($totalVoteValue + (($vote - $totalVoteValue) / $amtVotes)) / 5) * 150;

echo $width;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:51:29+00:00Added an answer on May 23, 2026 at 2:51 pm
        xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
    

    adding this may help (before send after open)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this plugin: http://www.fyneworks.com/jquery/star-rating/ Is it possible to put a click function inside
I have an application with ajax star rating but when i am assigning value
Right now I have a 5 star rating system in my application, but the
I'm using the source code found on this site here: http://webtint.net/tutorials/5-star-rating-system-in-php-mysql-and-jquery/comment-page-1/#comment-2562 A fantastic resource,
I have this code: <div id=star-rating> <script type=text/javascript> $(function(){ $('#star-rating form').submit(function(){ $('.test',this).html(''); $('input',this).each(function(){ if(this.checked)
I already have a 5 star rating system in place (user votes 1-5...and average
I have this star rating, I implemented from jQuery and I need to save
Right Now I have a 5 star rating with values ranging from 1-5. Behind
5 star rating script I have is made based on this tutorial http://php.about.com/od/finishedphp1/ss/rating_script.htm I
i am using jquery star rating plugin . I have a very problem: i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.