Как сохранить значения JQuery в базе данных?
Вот мои коды, я делаю оценки, я могу отображать звезды, которые я выбрал на этикетке, но когда я сохраняю в базе данных, значение равно 0 . Как мне решить это?
Review.aspx
<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";
}
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";
}
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";
}
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";
}
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";
}
document.getElementById('lblRate').innerText = temp;
return false;
}
</script>
<form id="form1" runat="server">
<h1>Reviews for Dog Sitter , Please Rate!</h1>
<h2>You are giving ratings to:</h2>
<p>Sitter's Name:<asp:Label ID="SitterLabel" runat="server" Text=""></asp:Label>
</p>
<p>Served you on :<asp:Label ID="DateLabel" runat="server" Text=""></asp:Label>
</p>
<div>
<asp:Button BorderStyle="None" ID="Rating1" onmouseover="return Decide(1);" OnClientClick="return Decide(1);"
Height="50px" Width="50px" CssClass="Empty" runat="server" />
<asp:Button BorderStyle="None" ID="Rating2" onmouseover="return Decide(2);" OnClientClick="return Decide(2);"
Height="50px" Width="50px" CssClass="Empty" runat="server" />
<asp:Button BorderStyle="None" ID="Rating3" onmouseover="return Decide(3);" OnClientClick="return Decide(3);"
Height="50px" Width="50px" CssClass="Empty" runat="server" />
<asp:Button BorderStyle="None" ID="Rating4" onmouseover="return Decide(4);" OnClientClick="return Decide(4);"
Height="50px" Width="50px" CssClass="Empty" runat="server" />
<asp:Button BorderStyle="None" ID="Rating5" onmouseover="return Decide(5);" OnClientClick="return Decide(5);"
Height="50px" Width="50px" CssClass="Empty" runat="server" />
</div>
<br />
<br />
<div id="lblrate">
<strong><span class="auto-style1">You have given this amount of stars: </span></strong>
<asp:Label ID="lblRate" runat="server" Text="" style="font-size:40px; font-family:Arial" ></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" Height="121px" Width="295px" OnClick="Button1_Click" />
</div>
</form>
Review.aspx.cs
public partial class Review : System.Web.UI.Page
{
string connstring = ConfigurationManager.ConnectionStrings["FosterDogContext"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(connstring);
SqlCommand cmd = new SqlCommand("insert into Review(reviewNo) values('"+lblRate.Text+"')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("ReviewDone.aspx");
}
}