Ok, so I have this list and I am using jQuery to make it selectable with the following code:
Javascript:
<script language="javascript" type="text/javascript">
$(function() {
$( "#server_list" ).selectable({
stop: function() {
var result = $( "#select-result" ).empty();
$( ".ui-selected", this ).each(function() {
var index = $( "#selectable li" ).index( this );
result.append( " #" + ( index + 1 ) );
});
}
});
});
</script>
List:
<ul id="server_list">
{foreach from=$servers item=server}
<li id="{$server.id}"><img src="{$url}/images/serverstatus.php?name={$server.name}&status={$server.status}&port={$server.port}&playercount={$server.playercount}" alt="{$server.name}" /></li>
{/foreach}
</ul>
Also I have a form element named “sid” I was wondering how do I change the value of it to the ID of the selected item?
You can select the input element by using attribute selector and use
val()method to set its value with the id of selected item.