在级联选择中显示所选选项的名称

时间:2019-01-29 12:43:15

标签: javascript jquery

我正在使用jquery插件显示级联选择。我需要以字符串显示在它们下面的选择框中选择的值。谁能帮我这个忙。

<div class="container">
    <form method="post" action="#">
        <p>Enter details</p>
    </form>
</div>
<div>display selected values string here</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="jquery.chained.selects.js"></script>
<script type="text/javascript">
    var chainedData = {};
    var text ='{"JavaScript": {"jQuery": {"1": "jQuery UI"},"React": {"2": "React Native"}},"HTML": {"XML": {"HTML5": {"3": "HTML5/CSS3"}}},"More": {"AA": {"4": "AAA"},"AB": {"5": "ABA"},"AC": {"ABC": {"6": "ABCA","7": "ABCB"}}}}';
    function loadJson() {
        $("form select").remove();
        $("<select name=\"example_select\" id=\"example-select\"></select>").insertAfter("p");
        chainedData = JSON.parse(text);
        $('#example-select').chainedSelects({
            data: chainedData,
            loggingEnabled: true,
            placeholder:'Select'
        });
    }

    $(document).ready(function () {
        $("#load_json").click(loadJson);
        loadJson();
    });
</script>

0 个答案:

没有答案