update slice prefix in slice name field when site is changed slice create page
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 62aa96a..9e88581 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -755,13 +755,19 @@
         for node in Node.objects.all():
             deployment_nodes.append( (node.deployment.id, node.id, node.name) )
 
+        sites = {}
+        for site in Site.objects.all():
+            sites[site.id] = site.login_base 
+        
         context["deployment_nodes"] = deployment_nodes
+        context["sites"] = sites
 
         return super(SliceAdmin, self).render_change_form(request, context, add, change, form_url, obj)
 
     def formfield_for_foreignkey(self, db_field, request, **kwargs):
         if db_field.name == 'site':
             kwargs['queryset'] = Site.select_by_user(request.user)
+            kwargs['widget'] = forms.Select(attrs={'onChange': "update_slice_name(this, $($(this).closest('div')[0]).find('.field-name input')[0].id)"}) 
 
         return super(SliceAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
 
diff --git a/planetstack/templates/admin/core/slice/change_form.html b/planetstack/templates/admin/core/slice/change_form.html
index c94b580..e97364b 100644
--- a/planetstack/templates/admin/core/slice/change_form.html
+++ b/planetstack/templates/admin/core/slice/change_form.html
@@ -8,6 +8,13 @@
 {% endfor %}
 ];
 
+sites = [
+{% for s in sites %}
+  [{{ s.0 }}, {{ s.1 }}],
+{% endfor %}
+];
+ 
+
 function update_nodes(deployment_select, node_select_id) {
     deployment_id = $(deployment_select).val();
     html = "<option value=''>---------</option>\n";
@@ -20,6 +27,15 @@
     //console.log(html);
     $("#"+node_select_id).empty().append(html);
 }
+
+function update_slice_prefix(site_select, slice_name_id) {
+    site_id = $(site_select).val();
+    slice_prefix="";
+    if (site_id in sites) {
+        slice_prefix=sites[site_id]+"_";
+    }
+    $("#"+slice_name_id).val(slice_prefix); 
+}
 </script>
 
 {% endblock %}