English 中文(简体)
几个选定的低落箱增加价值
原标题:several select dropdown boxes to add values

如果两个不同的选择下降的数值相同,如果它们有相同的“名称”,然后将总价值归入使用舱位的阵列,那么我如何能够在选择(不提交)时将这两个数值加在一起?

EDIT

For a little clarification, I am dynamically creating the list which needs to look like this

BOX A, BOX A, TITLE

BOX B, BOX B, TITLE

BOX C, BOX C, TITLE etc...

每个清单都有所不同,很少相同。 随后,这些箱子可以是DE或F。 选定(目前为交换) 如果价值不是空的,那么所有相应的箱子都需要加在一起,然后被推入一个适当的阵列。

var s=[sumOfAs, sumOfBs, sumOfCs];

I hope this helps... Also the back end is PHP THANKS!

EDIT

这里是把第一套价值观推向一阵的支架。

$("#selectionBox select").change(function(){
    s = [];
    $("#selectionBox select option:selected").each(function(){
        $("#selected_songs").text(  );

        var v = $(this).val();
        if(v !=   ){
            s.push(v);
        }
        if(s != ""){ 
            $( #selectionButton ).show(); 
            var mw = $("#list_month_New").val();
            var dw = $("#list_day_New").val();
            var yw = $("#list_year_New").val();
            var t = $("#listTitle").val();
            if(mw == "" || dw == "" || yw == ""){
                $("#songListWarning").show();
            }else{
                $("#songListWarning").hide();
            }
        }else{
            $("#list_month_New").val();
            $("#list_day_New").val();
            $("#list_year_New").val();
            $("#listTitle").val();
            $( #selectionButton ).hide();
        }
    });
    s.sort();
    jQuery.each(s, function(){
            O = "";
            O = this+"<br />";
            str = /&(.+)/.exec(O)[1];
            num = O.replace(/-.*/,   );
            fullString =  <span style="color:black"> +num+ </span> -  +str;
            $("#selected_songs").append(fullString);
    });

I just need to figure out how to add another value to the initial value?

最佳回答
var runningTotals = {};
$( select ).each(function() {
    var $this = $(this);
    var name = $this.attr("name");
    var val = runningTotals[name];
    if (!val) {
        val = 0;
    }
    val += +($this.val());
    runningTotals[name] = val;
});

请参看fiddle


EDIT Edited to update for the change edit you made

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签