How to make th: value of select have multiple values

I verified and fixed it.

index.html


<select id=“select_mult”>
	<option th:each="user : ${user_list}" th:value="${user.id} + ',' + ${user.name}">[[${user.name}]]
</select>

<span id="user_name"></span>

script.js


$(function(){
	$('#select_mult').change(function(){
		var str = $('#select_mult option:selected').val().split(',');
		var id = str[0];
		var name = str[1];
		
		$('#user_name').val(id);
        $('#user_name').text(name);
	});
});


Recommended Posts

How to make th: value of select have multiple values
Note to have multiple values in HashMap
Summary of how to select elements in Selenium
[Java] How to make multiple for loops single
[Java] How to get the maximum value of HashMap
[Ruby] How to extract a specific value from an array under multiple conditions [select / each]
How to display the select field of time_select every 30 minutes
Java --How to make JTable
How to change the setting value of Springboot Hikari CP
[Rails] How to make seed
What is an immutable object? [Explanation of how to make]
How to install JavaScript library "select2" that makes multiple selections of selectbox fashionable in Rails 6.0
How to increment the value of Map in one line in Java
How to make a Java container
How to make a JDBC driver
How to use setDefaultCloseOperation () of JFrame
How to make a splash screen
How to make a Jenkins plugin
[Swift] How to replace multiple strings
How to make a Java array
[Android] How to make Dialog Fragment
How to output the sum of any three numbers, excluding the same value
I tried to make a parent class of a value object in Ruby
How to read Body of Request multiple times with Spring Boot + Spring Security
Procedure to make the value of the property file visible in Spring Boot
How to change the value of a variable at a breakpoint in intelliJ
Android development, how to check null in the value of JSON object
How to make the schema of the URL generated by Rails URL helper https
How to make a Java calendar Summary
How to name variables 7 selections of discomfort
[java] Summary of how to handle char
Summary of how to write annotation arguments
How to have params in link_to method
How to determine the number of parallels
How to make a Discord bot (Java)
[Java] [Maven3] Summary of how to use Maven3
Java: How to send values from Servlet to Servlet
How to sort the List of SelectItem
[Struts] How to pass values between jsps
How to make asynchronous pagenations using Kaminari
How to switch between multiple Java versions
How to execute multiple commands in docker-compose.yml
[Ruby on Rails] How to make the link destination part of the specified id
How to convert a value of a different type and assign it to another variable
Rails6 I want to make an array of values with a check box
How to make a unique combination of data in the rails intermediate table