← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3645: Load Patient Attribute forms by ajax.

 

------------------------------------------------------------
revno: 3645
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-05-18 10:07:12 +0700
message:
  Load Patient Attribute forms by ajax.
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttribute.vm
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2011-05-18 01:07:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2011-05-18 03:07:12 +0000
@@ -586,9 +586,15 @@
 		<action name="programAttribute"
 			class="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction">
 			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/programAttribute.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
+			<param name="javascripts">javascript/commons.js,javascript/programAttribute.js</param>
+		</action>
+		
+		<action name="programAttributeList"
+			class="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction">
+			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/programAttributeList.vm</param>
-			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
-			<param name="javascripts">javascript/programAttribute.js</param>
 		</action>
 
 		<action name="getProgramAttribute"
@@ -607,15 +613,15 @@
 
 		<action name="addProgramAttribute"
 			class="org.hisp.dhis.patient.action.program.AddProgramAttributeAction">
-			<result name="success" type="redirect">programAttribute.action
-			</result>
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_ADD</param>
 		</action>
 
 		<action name="updateProgramAttribute"
 			class="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction">
-			<result name="success" type="redirect">programAttribute.action
-			</result>
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_UPDATE</param>
 		</action>
 
@@ -631,23 +637,18 @@
 		</action>
 
 		<action name="showAddProgramAttributeForm" class="org.hisp.dhis.patient.action.NoAction">
-			<result name="success" type="velocity">/main.vm</result>
+			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/addProgramAttributeForm.vm</param>
-			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
-			<param name="javascripts">javascript/programAttribute.js</param>
 			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_ADD</param>
 		</action>
 
 		<action name="showUpdateProgramAttributeForm"
 			class="org.hisp.dhis.patient.action.program.GetProgramAttributeAction">
-			<result name="success" type="velocity">/main.vm</result>
+			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/updateProgramAttributeForm.vm</param>
-			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
-			<param name="javascripts">javascript/programAttribute.js</param>
 			<param name="requiredAuthorities">F_PROGRAM_ATTRIBUTE_UPDATE</param>
 		</action>
 
-
 		<action name="validateProgramAttribute"
 			class="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction">
 			<result name="success" type="velocity-json">
@@ -959,16 +960,19 @@
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/caseAggregation.vm</param>
 			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
-			<param name="javascripts">javascript/caseaggregation.js</param>
+			<param name="javascripts">javascript/commons.js,javascript/caseaggregation.js</param>
+		</action>
+		
+		<action name="caseAggregationList"
+			class="org.hisp.dhis.patient.action.caseaggregation.GetAllCaseAggregationConditionAction">
+			<result name="success" type="velocity">/content.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/caseAggregationList.vm</param>
 		</action>
 
 		<action name="showAddCaseAggregationForm"
 			class="org.hisp.dhis.patient.action.caseaggregation.ShowCaseAggregationConditionFormAction">
-			<result name="success" type="velocity">/main.vm</result>
+			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/addCaseAggregation.vm</param>
-			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
-			<param name="javascripts">javascript/commons.js,
-				javascript/caseaggregation.js</param>
 		</action>
 
 		<action name="showUpdateCaseAggregationForm"
@@ -979,7 +983,7 @@
 
 		<action name="updateCaseAggregationFormChain"
 			class="org.hisp.dhis.patient.action.caseaggregation.GetCaseAggregationConditionAction">
-			<result name="success" type="velocity">/main.vm</result>
+			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/updateCaseAggregation.vm</param>
 			<param name="menu">/dhis-web-maintenance-patient/patientAndProgramMenu.vm</param>
 			<param name="javascripts">javascript/commons.js,

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm	2011-05-16 09:29:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm	2011-05-18 03:07:12 +0000
@@ -34,6 +34,7 @@
 </script>
 				
 <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:onClickBackBtn();" style="width:10em">
+<p></p>
 													
 <h3>$i18n.getString( "add_new_patient_attribute" )</h3>
 <form id="addPatientAttributeForm" name='addPatientAttributeForm' action='addPatientAttribute.action' method="post">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm	2011-04-28 08:15:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramAttributeForm.vm	2011-05-18 03:07:12 +0000
@@ -4,20 +4,30 @@
 	var i18n_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
 
 	var isSubmit = true;
-	jQuery(document).ready(	function(){
-			
-			validation( 'addProgramAttributeForm', function(form){
-				if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) {
-					form.submit();
+	jQuery('#addProgramAttributeForm').ready(	function(){
+
+		validation( 'addProgramAttributeForm', function(form){
+				if( isSubmit )
+				{
+					addProgramAttribute();
 				}
 			}, function(){
-				isSubmit = true;
-				jQuery.each($('#addProgramAttributeForm').serializeArray(), function(i, field) {
-					if( field.value == ""){
-						setInnerHTML("attrMessage", i18n_field_is_required);
-						isSubmit = false;
-					}
-				});
+				isSubmit = ATTRIBUTE_OPTION.checkOnSubmit();
+				
+				if( isSubmit )
+				{
+					var fields = $("#addProgramAttributeForm").serializeArray();
+					jQuery.each(fields, function(i, field) {
+						if(  field.name.match("^attrOption")=='attrOption' && field.value == ""){
+							setInnerHTML( "attrMessage", i18n_field_is_required );
+							isSubmit = false;
+						}
+					});
+					
+				}else
+				{
+					setInnerHTML( "attrMessage", i18n_at_least_2_option );
+				}
 			});
 		
 		jQuery("#attributeComboRow").hide();
@@ -25,7 +35,9 @@
 		checkValueIsExist( "name", "validateProgramAttribute.action");
 	});		
 </script>
-
+				
+<input type="button" value="$i18n.getString( 'back' )" onclick="javascript:onClickBackBtn();" style="width:10em">
+<p></p>
 																		
 <h3>$i18n.getString( "add_new_program_attribute" )</h3>
 <form id="addProgramAttributeForm" action="addProgramAttribute.action" method="post" >

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js	2010-11-09 02:09:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programAttribute.js	2011-05-18 03:07:12 +0000
@@ -27,6 +27,7 @@
 // -----------------------------------------------------------------------------
 // Remove Program Attribute
 // -----------------------------------------------------------------------------
+
 function removeProgramAttribute( programAttributeId, name )
 {
 	removeItem( programAttributeId, name, i18n_confirm_delete, 'removeProgramAttribute.action' );	
@@ -61,7 +62,6 @@
 			});
 			if( $("input","#attrOptionContainer").length < 2)
 			{
-				alert(i18n_at_least_2_option);
 				return false;
 			}else return true;
 		}
@@ -99,6 +99,92 @@
 	},
 	createInput : function ()
 	{
-		return "<tr><td><input type='text' name='attrOptions' style='width:28em'/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='"+i18n_remove_option+"'  onClick='ATTRIBUTE_OPTION.remove(this,null)'>[ - ]</a></td></tr>";
+		return "<tr><td><input type='text' name='attrOptions' id='attrOptions' style='width:28em'/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='"+i18n_remove_option+"'  onClick='ATTRIBUTE_OPTION.remove(this,null)'>[ - ]</a></td></tr>";
 	}
-}
\ No newline at end of file
+}
+
+// -----------------------------------------------------------------------------
+// Add Program Attribute
+// -----------------------------------------------------------------------------
+
+function showAddProgramAttributeForm()
+{
+	hideById('programAttributeList');
+	jQuery('#loaderDiv').show();
+	jQuery('#editProgramAttributeForm').load('showAddProgramAttributeForm.action',
+	{
+	}, function()
+	{
+		showById('editProgramAttributeForm');
+		jQuery('#loaderDiv').hide();
+	});
+}
+
+function addProgramAttribute()
+{	
+	$.ajax({
+		type: "POST",
+		url: 'addProgramAttribute.action',
+		data: getParamsForDiv('addProgramAttributeForm'),
+		success: function( json ) {
+			if( json.response == 'success')
+			{
+				onClickBackBtn();
+			}
+		}
+	});
+	
+    return false;
+}
+
+// -----------------------------------------------------------------------------
+// Update Program Attribute
+// -----------------------------------------------------------------------------
+
+function showUpdateProgramAttributeForm( programAttributeId )
+{
+	hideById('programAttributeList');
+	jQuery('#loaderDiv').show();
+	jQuery('#editProgramAttributeForm').load('showUpdateProgramAttributeForm.action',
+	{
+		id:programAttributeId
+	}, function()
+	{
+		showById('editProgramAttributeForm');
+		jQuery('#loaderDiv').hide();
+	});
+}
+
+function updateProgramAttribute()
+{	
+	$.ajax({
+		type: "POST",
+		url: 'updateProgramAttribute.action',
+		data: getParamsForDiv('updateProgramAttributeForm'),
+		success: function( json ) {
+			if( json.response == 'success')
+			{
+				onClickBackBtn();
+			}
+		}
+	});
+	
+    return false;
+}
+
+// ------------------------------------------------------------------
+// Click Back button
+// ------------------------------------------------------------------
+
+function onClickBackBtn()
+{
+	hideById('editProgramAttributeForm');	
+	jQuery('#loaderDiv').show();
+	jQuery('#programAttributeList').load('programAttributeList.action',
+	{
+	}, function()
+	{
+		showById('programAttributeList');
+		jQuery('#loaderDiv').hide();
+	});
+}	

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttribute.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttribute.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttribute.vm	2011-05-18 03:07:12 +0000
@@ -0,0 +1,30 @@
+<div id='programAttributeList'>
+	#parse( "/dhis-web-maintenance-patient/programAttributeList.vm" )
+</div>
+
+#parse( "/dhis-web-commons/loader/loader.vm" )
+
+<div id='editProgramAttributeForm'></div>
+<p></p>
+
+<span id='message'></span>
+
+
+<script type="text/javascript">
+	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient_attribute" ) , "'" )';
+	var i18n_adding_patient_atttibute_failed = '$encoder.jsEscape( $i18n.getString( "adding_patient_attribute_failed" ), "'")';
+	var i18n_updating_house_hold_failed = '$encoder.jsEscape( $i18n.getString( "updating_patient_attribute_failed" ), "'")';	
+	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';	
+    var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
+    var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
+    var i18n_number = '$encoder.jsEscape( $i18n.getString( "number" ) , "'")';
+    var i18n_yes_no = '$encoder.jsEscape( $i18n.getString( "yes_no" ) , "'")';
+    var i18n_text = '$encoder.jsEscape( $i18n.getString( "text" ) , "'")';
+    var i18n_date = '$encoder.jsEscape( $i18n.getString( "date" ) , "'")';
+    var i18n_combo = '$encoder.jsEscape( $i18n.getString( "combo" ) , "'")';
+	var i18n_processing = '$encoder.jsEscape( $i18n.getString( "processing" ) , "'")';
+	var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
+	var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
+	var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
+	var i18n_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
+</script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm	2010-11-09 02:09:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programAttributeList.vm	2011-05-18 03:07:12 +0000
@@ -9,7 +9,7 @@
 			  <col width="20">     
 			  <tr>
 				<td></td>
-				<td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddProgramAttributeForm.action'" style="width:70px"></td>
+				<td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="javascript:showAddProgramAttributeForm();" style="width:70px"></td>
 			  </tr>
 			  <tr>            
 				<th>$i18n.getString( "name" )</th>
@@ -17,13 +17,14 @@
 			  </tr>
 
 			  <tbody id="list">
+				#set( $mark = false )
 				#foreach( $programAttribute in $programAttributes )
-				  <tr id="tr${programAttribute.id}">
+				  <tr id="tr${programAttribute.id}" #alternate( $mark )>
 				  
 					<td>$programAttribute.name</td>                
 					
 					<td style="text-align:center">
-					  <a href="showUpdateProgramAttributeForm.action?id=$programAttribute.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
+					  <a href="javascript:showUpdateProgramAttributeForm('$programAttribute.id')" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
 					</td>
 					
 					<td style="text-align:center">
@@ -31,14 +32,14 @@
 					</td>            
 					
 					<td style="text-align:center">
-					  <a href="javascript:showProgramAttributeDetails( $programAttribute.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>
+					  <a href="javascript:showProgramAttributeDetails( '$programAttribute.id' )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>
 					</td>
 					
 				  </tr>
+				  #set( $mark = !$mark)
 				#end
-
 			  </tbody>
-
+			  
 			</table>
 		</td>
 		<td style="width:20em; padding-left:2em; vertical-align:top">
@@ -56,21 +57,3 @@
 		</td>
   </tr>
 </table>
-
-
-<script type="text/javascript">
-	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_patient_attribute" ) , "'" )';
-	var i18n_adding_patient_atttibute_failed = '$encoder.jsEscape( $i18n.getString( "adding_patient_attribute_failed" ), "'")';
-	var i18n_updating_house_hold_failed = '$encoder.jsEscape( $i18n.getString( "updating_patient_attribute_failed" ), "'")';	
-	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ), "'")';	
-    var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
-    var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
-    var i18n_number = '$encoder.jsEscape( $i18n.getString( "number" ) , "'")';
-    var i18n_yes_no = '$encoder.jsEscape( $i18n.getString( "yes_no" ) , "'")';
-    var i18n_text = '$encoder.jsEscape( $i18n.getString( "text" ) , "'")';
-    var i18n_date = '$encoder.jsEscape( $i18n.getString( "date" ) , "'")';
-    var i18n_combo = '$encoder.jsEscape( $i18n.getString( "combo" ) , "'")';
-	var i18n_processing = '$encoder.jsEscape( $i18n.getString( "processing" ) , "'")';
-	var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
-</script>
-</script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm	2011-05-16 09:29:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm	2011-05-18 03:07:12 +0000
@@ -13,7 +13,7 @@
 				
 				if( isSubmit )
 				{
-					var fields = $("#addPatientAttributeForm").serializeArray();
+					var fields = $("#updatePatientAttributeForm").serializeArray();
 					jQuery.each(fields, function(i, field) {
 						if(  field.name.match("^attrOption")=='attrOption' && field.value == ""){
 							setInnerHTML( "attrMessage", i18n_field_is_required );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm	2011-04-28 08:15:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramAttributeForm.vm	2011-05-18 03:07:12 +0000
@@ -1,28 +1,38 @@
 <script>
-	var i18n_remove_option = '$encoder.jsEscape( $i18n.getString( "remove_option" ) , "'") ';
-	var i18n_field_is_required = '$encoder.jsEscape( $i18n.getString( "field_is_required" ) , "'") ';
-	var i18n_at_least_2_option = '$encoder.jsEscape( $i18n.getString( "at_least_2_option" ) , "'") ';
 	var isSubmit = true;
-	jQuery(document).ready(	function(){
-			
+	
+	jQuery('#updateProgramAttributeForm').ready(	function(){
+
 			validation( 'updateProgramAttributeForm', function(form){
-				if( isSubmit && ATTRIBUTE_OPTION.checkOnSubmit() ) {
-					form.submit();
+				if( isSubmit )
+				{
+					updateProgramAttribute();
 				}
 			}, function(){
-				isSubmit = true;
-				jQuery.each($('#updateProgramAttributeForm').serializeArray(), function(i, field) {
-					if( field.value == ""){
-						setInnerHTML("attrMessage", i18n_field_is_required);
-						isSubmit = false;
-					}
-				});
-			}); 
+				isSubmit = ATTRIBUTE_OPTION.checkOnSubmit();
+				
+				if( isSubmit )
+				{
+					var fields = $("#updateProgramAttributeForm").serializeArray();
+					jQuery.each(fields, function(i, field) {
+						if(  field.name.match("^attrOption")=='attrOption' && field.value == ""){
+							setInnerHTML( "attrMessage", i18n_field_is_required );
+							isSubmit = false;
+						}
+					});
+					
+				}else
+				{
+					setInnerHTML( "attrMessage", i18n_at_least_2_option );
+				}
+			});
 			
 		checkValueIsExist( "name", "validateProgramAttribute.action", {id:getFieldValue('id')});
 	});		
 </script>
-
+				
+<input type="button" value="$i18n.getString( 'back' )" onclick="javascript:onClickBackBtn();" style="width:10em">
+<p></p>
 																		
 <h3>$i18n.getString( "update_new_program_attribute" )</h3>
 <form id="updateProgramAttributeForm" action="updateProgramAttribute.action" method="post" >