When I don't use OnClick
I can see the effect of mousehover:
When I do use OnClick
I do not see a mousehover effect:
This is my code:
<head>
<title></title>
<style type="text/css">
.Empty
{
background: URL("images/Category/Empty.gif"") no-repeat right top;
}
.Empty:hover
{
background: url("img src="images/Category/Filled.gif") no-repeat right top;
}
.Filled
{
background: url("img src="images/Category/Filled.gif") no-repeat right top;
}
.Filled
{
background-image: <img src= "images/Category/Filled.gif" />;
}
</style>
<script type="text/javascript">
function Decide(option) {
var temp = "";
document.getElementById('lblRate').innerText = "";
if (option == 1) {
document.getElementById('Rating1').className = "Filled";
document.getElementById('Rating2').className = "Empty";
document.getElementById('Rating3').className = "Empty";
document.getElementById('Rating4').className = "Empty";
document.getElementById('Rating5').className = "Empty";
temp = "1-Poor";
}
if (option == 2) {
document.getElementById('Rating1').className = "Filled";
document.getElementById('Rating2').className = "Filled";
document.getElementById('Rating3').className = "Empty";
document.getElementById('Rating4').className = "Empty";
document.getElementById('Rating5').className = "Empty";
temp = "2-Ok";
}
if (option == 3) {
document.getElementById('Rating1').className = "Filled";
document.getElementById('Rating2').className = "Filled";
document.getElementById('Rating3').className = "Filled";
document.getElementById('Rating4').className = "Empty";
document.getElementById('Rating5').className = "Empty";
temp = "3-Fair";
}
if (option == 4) {
document.getElementById('Rating1').className = "Filled";
document.getElementById('Rating2').className = "Filled";
document.getElementById('Rating3').className = "Filled";
document.getElementById('Rating4').className = "Filled";
document.getElementById('Rating5').className = "Empty";
temp = "4-Good";
}
if (option == 5) {
document.getElementById('Rating1').className = "Filled";
document.getElementById('Rating2').className = "Filled";
document.getElementById('Rating3').className = "Filled";
document.getElementById('Rating4').className = "Filled";
document.getElementById('Rating5').className = "Filled";
temp = "5-Nice";
}
document.getElementById('lblRate').innerText = temp;
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Rate The Product"></asp:Label><br />
<asp:ImageButton BorderStyle="None" ID="Rating1" onmouseover="return Decide(1);"
OnClientClick="return Decide(1);" Height="20px" Width="20px" CssClass="Empty"
src="images/Category/Empty.gif" runat="server" OnClick="imagebutton" />
<asp:ImageButton BorderStyle="None" ID="Rating2" onmouseover="return Decide(2);"
OnClientClick="return Decide(2);" Height="20px" Width="20px" CssClass="Empty"
src="images/Category/Filled.gif" runat="server" OnClick="imagebutton" />
<asp:ImageButton BorderStyle="None" ID="Rating3" onmouseover="return Decide(3);"
OnClientClick="return Decide(3);" Height="20px" Width="20px" CssClass="Empty"
src="images/Category/Filled.gif" runat="server" OnClick="imagebutton" />
<asp:ImageButton BorderStyle="None" ID="Rating4" onmouseover="return Decide(4);"
OnClientClick="return Decide(4);" Height="20px" Width="20px" CssClass="Empty"
src="images/Category/Filled.gif" runat="server" OnClick="imagebutton" />
<asp:ImageButton BorderStyle="None" ID="Rating5" onmouseover="return Decide(5);"
OnClientClick="return Decide(5);" Height="20px" Width="20px" CssClass="Empty"
src="images/Category/Filled.gif" runat="server" On Click="image button" />
<br />
<br />
<asp:Label ID="lblRate" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
I have used this code for rating and it's working, but the issue is that when I click on image button I want it to redirect me to the next page taking its value. But when I used $("p").click(function () { });
This method for OnClick
will redirect me to the next page but the problem is, it will stop showing me value that is shown on mouse hover time.