form.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {include file="public/header" /}
  2. <div class="page">
  3. <form id="brand_form" method="post" name="form1" enctype="multipart/form-data">
  4. <input type="hidden" name="brand_id" value="{$brand_array.brand_id}" />
  5. <table class="ds-default-table">
  6. <tbody>
  7. <tr class="noborder">
  8. <td class="required w120"><label class="validation">{$Think.lang.brand_index_name}:</label></td>
  9. <td class="vatop rowform"><input type="text" value="{$brand_array.brand_name}" name="brand_name" id="brand_name" class="txt"></td>
  10. <td class="vatop tips"></td>
  11. </tr>
  12. <tr class="noborder">
  13. <td class="required"><label class="validation">{$Think.lang.brand_name_initial}:</label></td>
  14. <td class="vatop rowform"><input type="text" value="{$brand_array.brand_initial}" name="brand_initial" id="brand_initial" class="txt"></td>
  15. <td class="vatop tips">{$Think.lang.brand_name_initial_tips}</td>
  16. </tr>
  17. <tr class="noborder">
  18. <td class="required">{$Think.lang.brand_index_class}: </td>
  19. <td class="vatop rowform" id="gcategory"><input type="hidden" value="{$brand_array.gc_id}" name="class_id" class="mls_id">
  20. <input type="hidden" value="{$brand_array.brand_class}" name="brand_class" class="mls_name">
  21. <span class="mr10">{$brand_array.brand_class}</span>
  22. {notempty name="brand_array.class_id"}
  23. <input class="edit_gcategory" type="button" value="{$Think.lang.ds_edit}">
  24. {/notempty}
  25. <select {notempty name="brand_array.class_id"}style="display:none;"{/notempty} class="class-select">
  26. <option value="0">{$Think.lang.ds_please_choose}...</option>
  27. {notempty name="gc_list"}
  28. {foreach name="gc_list" item="v"}
  29. {if $v.gc_parent_id == '0'}
  30. <option value="{$v.gc_id}">{$v.gc_name}</option>
  31. {/if}
  32. {/foreach}
  33. {/notempty}
  34. </select>
  35. </td>
  36. <td class="vatop tips">{$Think.lang.brand_index_class_tips}</td>
  37. </tr>
  38. <tr class="noborder">
  39. <td class="required">{$Think.lang.brand_index_pic_sign}: </td>
  40. <td class="vatop rowform">
  41. {notempty name="$brand_array.brand_pic"}
  42. <span class="type-file-show"> <img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
  43. <div class="type-file-preview" style="display: none;"><img id="view_img" src="{:ds_get_pic(ATTACH_BRAND,$brand_array.brand_pic)}"></div>
  44. </span>
  45. {/notempty}
  46. <span class="type-file-box">
  47. <input type='text' name='brand_pic' id='brand_pic' class='type-file-text' />
  48. <input type='button' name='button' id='button' value='上传' class='type-file-button' />
  49. <input name="_pic" type="file" class="type-file-file" id="_pic" size="30" hidefocus="true" />
  50. </span>
  51. </td>
  52. <td class="vatop tips">{$Think.lang.brand_index_upload_tips}{$Think.lang.brand_add_support_type}gif,jpg,png</td>
  53. </tr>
  54. <tr class="noborder">
  55. <td class="required">{$Think.lang.brand_showtype}: </td>
  56. <td class="vatop rowform">
  57. <input id="brand_showtype_0" type="radio" {if $brand_array.brand_showtype==0}checked{/if} value="0" style="margin-bottom:6px;" name="brand_showtype" />
  58. <label for="brand_showtype_0">{$Think.lang.brand_showtype_img}</label>
  59. <input id="brand_showtype_1" type="radio" {if $brand_array.brand_showtype==1}checked{/if} value="1" style="margin-bottom:6px;" name="brand_showtype" />
  60. <label for="brand_showtype_1">{$Think.lang.brand_showtype_text}</label>
  61. </td>
  62. <td class="vatop tips">{$Think.lang.brand_showtype_tips}</td>
  63. </tr>
  64. <tr class="noborder">
  65. <td class="required">{$Think.lang.brand_add_if_recommend}: </td>
  66. <td class="vatop rowform onoff"><label for="brand_recommend1" class="cb-enable {if $brand_array.brand_recommend == '1'}selected{/if}" title="{$Think.lang.ds_yes}"><span>{$Think.lang.ds_yes}</span></label>
  67. <label for="brand_recommend0" class="cb-disable {if $brand_array.brand_recommend == '0'}selected{/if}" title="{$Think.lang.ds_no}"><span>{$Think.lang.ds_no}</span></label>
  68. <input id="brand_recommend1" name="brand_recommend" {if $brand_array.brand_recommend == '1'}checked="checked"{/if} value="1" type="radio">
  69. <input id="brand_recommend0" name="brand_recommend" {if $brand_array.brand_recommend == '0'}checked="checked"{/if} value="0" type="radio"></td>
  70. <td class="vatop tips">{$Think.lang.brand_index_recommend_tips}</td>
  71. </tr>
  72. <tr>
  73. </tr>
  74. <tr class="noborder">
  75. <td class="required">{$Think.lang.ds_sort}: </td>
  76. <td class="vatop rowform"><input type="text" value="{$brand_array.brand_sort}" name="brand_sort" id="brand_sort" class="txt"></td>
  77. <td class="vatop tips">{$Think.lang.brand_add_update_sort}</td>
  78. </tr>
  79. </tbody>
  80. <tfoot>
  81. <tr class="tfoot">
  82. <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  83. </tr>
  84. </tfoot>
  85. </table>
  86. </form>
  87. </div>
  88. <script src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js"></script>
  89. <script>
  90. function call_back(picname){
  91. $('#brand_pic').val(picname);
  92. $('#view_img').attr('src','{$Think.UPLOAD_SITE_URL}/{$Think.ATTACH_BRAND}/'+picname);
  93. }
  94. //按钮先执行验证再提交表单
  95. $(function(){
  96. // 编辑分类时清除分类信息
  97. $('.edit_gcategory').click(function(){
  98. $('input[name="class_id"]').val('');
  99. $('input[name="brand_class"]').val('');
  100. });
  101. jQuery.validator.addMethod("initial", function(value, element) {
  102. return /^[A-Za-z0-9]$/i.test(value);
  103. }, "");
  104. $("#brand_form").validate({
  105. errorPlacement: function(error, element){
  106. error.appendTo(element.parent().parent().find('td:last'));
  107. },
  108. rules : {
  109. brand_name : {
  110. required : true,
  111. remote : {
  112. url :"{:url('Brand/ajax',['branch'=>'check_brand_name'])}",
  113. type:'get',
  114. data:{
  115. brand_name : function(){
  116. return $('#brand_name').val();
  117. },
  118. id : '{$brand_array.brand_id}'
  119. }
  120. }
  121. },
  122. brand_initial : {
  123. initial : true
  124. },
  125. brand_sort : {
  126. number : true,
  127. range : [0,255]
  128. }
  129. },
  130. messages : {
  131. brand_name : {
  132. required : '{$Think.lang.brand_add_name_null}',
  133. remote : '{$Think.lang.brand_add_name_exists}'
  134. },
  135. brand_initial : {
  136. initial : '{$Think.lang.brand_add_initial}'
  137. },
  138. brand_sort : {
  139. number : '{$Think.lang.brand_add_sort_int}',
  140. range : '{$Think.lang.class_sort_explain}'
  141. }
  142. }
  143. });
  144. });
  145. gcategoryInit('gcategory');
  146. </script>