Monday 25 March 2013

How to catch event after submit button click


<input type="button" value="Form Action" name="btnFormAction0" onclick="javascript: {ddwrt:GenFireServerEvent('__commit)')};alert('Your request has been submitted and we will get back to you once it is done');window.parent.location='http://server/site/Lists/list_name/AllItems.aspx'" />







 <input type="button" value="Submit" class="ms-ButtonHeightWidth" name="btnSubmit">
                             <xsl:attribute name="onclick">
                                errmsg = checkSolution();
     if(errmsg.length &gt; 0) {      
     }
     else {
      <xsl:value-of select="ddwrt:GenFireServerEvent('__commit;__redirectsource')" />
     }
      </xsl:attribute>
                       </input>










$(document).ready(function()
 {
     $("nobr:contains('Archived')").parent('h3').parent('td').parent('tr').hide();
     $("nobr:contains('AssignedTo')").parent('h3').parent('td').parent('tr').hide();

 });
 function PreSaveAction() {
 $("input[title$='Archived']").attr('checked',false);
  var userName = $().SPServices.SPGetCurrentUser({
  fieldName: "Name"
 });
 $("textarea[title='People Picker']").val(userName);
 $("div[title='People Picker']").text(userName);
 return true;
 }
function checkSolution(){
 // alert('hi');
 

  //alert('Confirm?');
  //window.parent.location='/Lists/TechnicalChallengeFeedBack/SendMail.aspx'
   var answer = confirm ("This will submit the data and you are not able to edit the data in future.Click on save if you want to edit the data in future .")
   if (answer)
   {
     $("input[title$='Archived']").attr('checked','checked');
     var userName = $().SPServices.SPGetCurrentUser({
     fieldName: "Name"
 });

 $("textarea[title='People Picker']").val(userName);
 $("div[title='People Picker']").text(userName);
   return '';
   }
   else
   {
      $("input[title$='Archived']").attr('checked',false);
      return 'Thanks.';
   }
}
</script>


No comments:

Post a Comment