简体   繁体   中英

place data into a hidden field

I have an onSelect method from a dropdown menu so when a user selects FirstOption he should get a value of 1 . At the end I have output which picks one of the selected option.

     $(document).ready(function () {
    $('.SelectID').click(function (e) { 
   var output;
        var select = $(this);
        switch (select.text()){
            case "FirstOption":
                var a = ("1");
                break;
            case "SecondOption":
                var b = ("2");
                break;
        }
        output = [a|| b];
    }

    <input id="text" type="hidden" />

I also have a hidden field, My question is how do i store output in that hidden field so i can use that value in another function.

To assign value to hidden add give id to your hidden field and then using jquery assign value like this $("#id").val(value to be assigned);

You make also use global variable for this purpose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM