Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在jQuery中读取选定的li值?_Jquery_Html - Fatal编程技术网

如何在jQuery中读取选定的li值?

如何在jQuery中读取选定的li值?,jquery,html,Jquery,Html,我试图将我的星级评定中的值作为一个数字传递到jQuery中,以便将其上载到数据库。例如,如果用户单击5颗星,数据值将为=“5”,我希望jQuery将星星读取为“5”,以便将5上传到数据库。但是,我只能上传第一个值,现在它将永远是“1” HTML 第2节 问题1:您如何评价您的总体体验 Javascript ////edited - just set a "dummy" variable so that we can proceed without selecting a

我试图将我的星级评定中的值作为一个数字传递到jQuery中,以便将其上载到数据库。例如,如果用户单击5颗星,数据值将为=“5”,我希望jQuery将星星读取为“5”,以便将5上传到数据库。但是,我只能上传第一个值,现在它将永远是“1”

HTML

第2节
问题1:您如何评价您的总体体验

Javascript

////edited - just set a "dummy" variable so that we can proceed without selecting an image. (Ignore Pic Upload)
var imgNewUserPictureName = "dummy";

// define global variable to receive all the values from new user form
var who;
var message;
var contactyn;
var stars; 

$("#btnFinish").bind("click", function () {
    // Call the savenewuser function
    savecontact();// if above all properly validated 

});

//Add New User to profile table in your database
function savecontact() {
    // Validates new user form
    if ($("#rateform").valid()) {
        var profileimage = imgNewUserPictureName; // dummy value
        // Receive all values from the New User form and store them in the global variables
        who = $("#selWho").val();
        message = $("#txtFeedback").val();
        contactyn = getRadioValue("rdoyn");
        stars = $(".star").attr("data-value"); // <-- **am stuck here now**


        // Define url variable to point to the newuser.php in your web server

            if (_validate()) {
            var url = serverURL() + "/savecontact.php";
            // Define JSONObject with new global variables, must put in specific order just like the one in the php
            var JSONObject = {
                "who": who,
                "message": message,
                "contactyn": contactyn,
                "stars": stars,
            };
///edited-只需设置一个“dummy”变量,这样我们就可以在不选择图像的情况下继续操作。(忽略图片上传)
var imgNewUserPictureName=“dummy”;
//定义全局变量以接收来自新用户窗体的所有值
世界卫生组织;
var消息;
var contactyn;
var星;
$(“#btnFinish”).bind(“单击”,函数(){
//调用savenewuser函数
savecontact();//如果首先正确验证
});
//将新用户添加到数据库中的配置文件表中
函数savecontact(){
//验证新用户表单
if($(“#rateform”).valid(){
var profileimage=imgNewUserPictureName;//伪值
//从新用户窗体接收所有值并将其存储在全局变量中
who=$(“#selWho”).val();
message=$(“#txtFeedback”).val();
contactyn=getRadioValue(“rdoyn”);

stars=$(“.star”).attr(“数据值”);//为什么不能添加
$(“.star”)。单击(函数(){$(this).addClass('selected')。兄弟姐妹('.selected')。removeClass('selected');})
,然后只检查所选的星:
stars=$(.star.selected”).attr(“数据值”)
?@AlonEitan当我这样做时,星星仍然等于1,尽管我选择了3颗星星。
////edited - just set a "dummy" variable so that we can proceed without selecting an image. (Ignore Pic Upload)
var imgNewUserPictureName = "dummy";

// define global variable to receive all the values from new user form
var who;
var message;
var contactyn;
var stars; 

$("#btnFinish").bind("click", function () {
    // Call the savenewuser function
    savecontact();// if above all properly validated 

});

//Add New User to profile table in your database
function savecontact() {
    // Validates new user form
    if ($("#rateform").valid()) {
        var profileimage = imgNewUserPictureName; // dummy value
        // Receive all values from the New User form and store them in the global variables
        who = $("#selWho").val();
        message = $("#txtFeedback").val();
        contactyn = getRadioValue("rdoyn");
        stars = $(".star").attr("data-value"); // <-- **am stuck here now**


        // Define url variable to point to the newuser.php in your web server

            if (_validate()) {
            var url = serverURL() + "/savecontact.php";
            // Define JSONObject with new global variables, must put in specific order just like the one in the php
            var JSONObject = {
                "who": who,
                "message": message,
                "contactyn": contactyn,
                "stars": stars,
            };