I’ve implemented the below solution on two different InfoPath forms for a cancel button to re-direct to the main page.
Publish the InfoPath form to the SharePoint, then create a web part page, add the InfoPath form web part and select the form you published, then add a content editor web part. Then press F12 of the web part page to get the button id in the InfoPath form web part. Then add the following JQuery code in the content editor web part HTML source.
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
setTimeout(function()
{$("#ctl00_m_g_956c867e_538d_4b27_a288_835afd04f1ea_FormControl1_V1_I1_B1").click(function
(){myFunction();});},3000);
});
function myFunction()
{
window.location.href="http://www.baidu.com";
}
</script>
Note: Please replacectl00_m_g_956c867e_538d_4b27_a288_835afd04f1ea_FormControl1_V1_I1_B1 with the ID of your button.
1. Form one submits data and the form remain open so the user can enter another record. After the record is saved the re-direct button doesn’t work.
2. Form two cancel button only works when I click twice.
Any ideas?