0e6437d150705e31ce479a3c314c300c10c0514c.svn-base 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.onReady(function() {
  7. Ext.QuickTips.init();
  8. // turn on validation errors beside the field globally
  9. Ext.form.Field.prototype.msgTarget = 'side';
  10. var bd = Ext.getBody();
  11. /*
  12. * ================ Simple form =======================
  13. */
  14. bd.createChild({
  15. tag : 'h2',
  16. html : 'Form 1 - Very Simple'
  17. });
  18. var simple = new Ext.FormPanel({
  19. labelWidth : 75, // label settings here cascade unless
  20. // overridden
  21. url : 'save-form.jsp',
  22. frame : true,
  23. title : 'Simple Form',
  24. bodyStyle : 'padding:5px 5px 0',
  25. width : 350,
  26. defaults : {
  27. width : 230
  28. },
  29. defaultType : 'textfield',
  30. items : [{
  31. fieldLabel : 'First Name',
  32. name : 'first',
  33. allowBlank : false
  34. }, {
  35. fieldLabel : 'Last Name',
  36. name : 'last'
  37. }, {
  38. fieldLabel : 'Company',
  39. name : 'company'
  40. }, {
  41. fieldLabel : 'Email',
  42. name : 'email',
  43. vtype : 'email'
  44. }, new Ext.form.TimeField({
  45. fieldLabel : 'Time',
  46. name : 'time',
  47. minValue : '8:00am',
  48. maxValue : '6:00pm'
  49. })],
  50. buttons : [{
  51. text : 'Save'
  52. }, {
  53. text : 'Cancel'
  54. }]
  55. });
  56. var submit = simple.addButton({
  57. text : 'Submit',
  58. disabled : false,
  59. handler : function() {
  60. // simple.items.get(0).name;
  61. var param = '{';
  62. for (var i = 0; i < simple.items.length; i++) {
  63. param = param
  64. + simple.items.get(i).name
  65. + ":\""
  66. + document.getElementsByName(simple.items.get(i).name)[0].value
  67. + "\",";
  68. }
  69. alert(param)
  70. simple.getForm().submit({
  71. url : 'sampleExtExc.jsp?param=' + param + ''
  72. });
  73. }
  74. });
  75. simple.render(document.body);
  76. /*
  77. * ================ Form xiaoxiao =======================
  78. */
  79. bd.createChild({
  80. tag : 'h2',
  81. html : 'Form xiaoxiao - Very Simple'
  82. });
  83. var simple1 = new Ext.FormPanel({
  84. labelWidth : 75, // label settings here cascade unless
  85. // overridden
  86. url : 'save-form.jsp',
  87. frame : true,
  88. title : 'Simple Form',
  89. bodyStyle : 'padding:5px 5px 0',
  90. width : 350,
  91. defaults : {
  92. width : 230
  93. },
  94. defaultType : 'textfield',
  95. items : [{
  96. fieldLabel : 'First1 Name',
  97. name : 'first1',
  98. allowBlank : false
  99. }, {
  100. fieldLabel : 'Last1 Name',
  101. name : 'last1'
  102. }, {
  103. fieldLabel : 'Company',
  104. name : 'company1'
  105. }, {
  106. fieldLabel : 'Email',
  107. name : 'email',
  108. vtype : 'email'
  109. }, new Ext.form.TimeField({
  110. fieldLabel : 'Time',
  111. name : 'time',
  112. minValue : '8:00am',
  113. maxValue : '6:00pm'
  114. })],
  115. buttons : [{
  116. text : 'Save'
  117. }, {
  118. text : 'Cancel'
  119. }]
  120. });
  121. var submit1 = simple1.addButton({
  122. text : 'Submit',
  123. disabled : false,
  124. handler : function() {
  125. simple1.getForm().submit({
  126. url : 'save-form.jsp'
  127. });
  128. }
  129. });
  130. simple1.render(document.body);
  131. });