开发者

Search string in value and toggle if it's here

ok, i'm all lost.

what i need to do is to check if the value contain the string element and if it does, delete the value part that contain that string. (kind of str.replace(something,'') )

here's tricky part, when the element is selected, i want all other tags that refers to sub-elements to get removed from that value (so if A is selected, i want (A-1) (A-2) to be suppressed from that value.

this must be done in Javascript/Jquery.

function swichOnOff(id){
    var text = '_'+id+'_';
    if(~$('#listeDel:contains('+text+')')){
        $('#li_'+id).css('background-color', '#990000');
        $('#listeDel').val($('#listeDel').val() + text);
    }else{
        $('#li_'+id).css('background-color', ''开发者_运维百科);
        $('#listeDel').val($('#listeDel').val().replace(text,''));
    }
    var tableau = new Array("U15", "U17","U20","SEN","VET");
    for(var i = 0; i < tableau.length; i++){
        var textVal = '('+id+'-'+tableau[i]+')';
        if(!~$('#listeDel:contains('+textVal+')')){
            $('#li_'+tableau[i]+id).css('background-color', '');
                $('#listeDel').val($('#listeDel').val().replace(textVal,''));
        }
    }
}

function swichOnOffClass(id, categ){
    var text = '_'+id+'_';
    var textVal = '('+id+'-'+categ+')';
    if(!~$('#listeDel:contains('+text+')')){
        $('#li_'+id).css('background-color', '');
        $('#listeDel').val($('#listeDel').val().replace(text,''));
    }

    if(!~$('#listeDel:contains('+textVal+')')){
        $('#li_'+categ+id).css('background-color', '');
        $('#listeDel').val($('#listeDel').val().replace(textVal,''));
    }else{
        $('#li_'+categ+id).css('background-color', '#AA0000');
        $('#listeDel').val($('#listeDel').val() + textVal);
    }
}

and there's the HTML.

<input type="hidden" name="listeDel" value="" id="listeDel">    --- JUST ADDED
<li id="li_128" style="background-color: rgb(153, 0, 0); "><span onclick="swichOnOff(&quot;128&quot;)" style="cursor:pointer;">SECRET NAME</span>
<ul>
<li>Sexe : SECRET NAME</li>
<li>Passeport : SECRET NAME</li>
<li>Grade/Rank : SECRET NAME</li>
<li>Date de naissance/DOB : SECRET NAME</li>
<li onclick="swichOnOffClass(&quot;128&quot;, &quot;U17&quot;)" id="li_U17128" style="background-color: rgb(170, 0, 0); ">Poids/Weight U17: -XX</li>
<li onclick="swichOnOffClass(&quot;128&quot;, &quot;SEN&quot;)" id="li_SEN128" style="background-color: rgb(170, 0, 0); ">Poids/Weight SEN : -XX</li>
<li>Nom du club/Club's name :SECRET NAME</li>
<li>Directeur Technique/Technical Director : SECRET NAME</li>   
</ul>
</li>

what i want is <input type="hidden" name="listeDel" value="" id="listeDel"> Become depending on the selection <input type="hidden" name="listeDel" value="_128_" id="listeDel"> OR <input type="hidden" name="listeDel" value="(128-SEN)(128-U17)" id="listeDel">

and <input type="hidden" name="listeDel" value="(128-SEN)" id="listeDel"> Become if main is selected <input type="hidden" name="listeDel" value="_128_" id="listeDel">

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜