开发者

Jquery to capture value and pass the value to a hidden field

I wrote a script that changes text based on user selection, which is working fine. I am not sure how using Jquery to capture the user selected selection and pass the value below to the hidden field ie replace the value="100" with the user selected value example value="trade"? -thanks

JQUERY

    $(document).ready(function() {    
        $('#trade').click(function() {
            $('#form').attr("class","trade");    //trade selected
            $('#trade').addClass("current");
            $('.lblMadlib112').text("some text1")开发者_如何转开发;// adds some text to this field           

         });

$('#football').click(function() {
            $('#formr').attr("class","football");//football    
            $('#football').addClass("current");
                       $('.lblMadlib112').text("some text here");// adds some text to this field      



         });

});

.NET stuff

<asp:HiddenField ID="hdnThemeId" runat="server" Value="100" />


You can give that control a class, like this:

<asp:HiddenField ID="hdnThemeId" CssClass="hdnThemeId" runat="server" Value="100" />

Then select it that way and use .val() to set the value, like this:

$('#trade').click(function() {
  $('#form').attr("class","trade");
  $('#trade').addClass("current");
  $('.lblMadlib112').text("some text1");
  $('.hdnThemeId').val("some value");
});


like

<span id='football' rel='football_value'>football</span>

and

$('#football').click(function() {
            $('#formr').attr("class","football");//football    
            $('#football').addClass("current");
            $('.lblMadlib112').text("some text here");// adds some text to this field 
            $('#hdnThemeId').val($(this).attr('rel'));     



         });

});


$('#hdnThemeId').val($('#trade').val());
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜