页面刷新后如何保留选定的下拉菜单

时间:2019-04-25 13:35:25

标签: javascript html ajax soy-templates

刷新页面后,我想保留选定的下拉列表,我使用的是Soy模板,我的问题是我不知道如何将JavaScript代码调用到Soy文件中

此下拉列表代码Soy模板端

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.9.1/d3.js"></script>
<button id='a'>1</button>
<button id='b'>1>2</button>
<button id='c'>2>3</button>
<button id='d'>1>3</button>
<button id='e'>3>4</button>
<button id='f'>4>5</button>
<svg width="400" height="400"></svg>

这是我要调用的javascript代码

<div  id="select-box1" class="select-box">
    <select id="membership" tabindex="10" name="MEMBERPROG" class="custom_select caret btn form-control membership_level" data-toggle="dropdown" placeholder="Select membership level" data-bind="value:MEMBERPROG">
        <option value="" selected="selected">Select membership level</option>
            {foreach $membershipLevel in $searchform.membershipLevels}
                <option id="{$membershipLevel.val}" value="{$membershipLevel.val}"{if $membershipLevel.val == $searchform.MEMBERPROG} selected="selected"{/if}>{$membershipLevel.name}</option>
            {/foreach}
   </select>
</div>

0 个答案:

没有答案