<script type="text/javascript">
var productStoreId = $('#productStoreId').val(); //productStoreId on change event
</script>
<select name="productStoreId" id="productStoreId">
<option value='' selected="selected">Select Location</option>
<#list productStoreList as store>
<option value='${store.productStoreId}'>${store.storeName}</option>
</#list>
</select>
<#assign AvblCrseList=prodStoreCoursesMap.get(${productStoreId})>// but productStoreId is undefined here.
I want productStoreId in a variable, because I have a map "prodStoreCoursesMap". I have to access it using the key productStoreId.
I want to access a map using the variable in the script tag as a key in the code in html/ftl.
<script type="text/javascript">
var productStoreId = $('#productStoreId').val(); // productStoreId on change event
</script>
This will only work at launch but won't update as you select from the dropdown.
Try this:
var productId;
$('#productStoreId').on('change', function(){
productId = $(this).val();
});
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.