I am trying to add a button to an Edit page that saves the current record and then adds an another based on fields within the form. The button is called "Add New Infraction". With the exception of the code in After Record Updated, this worked in my ASPRunner version of the project that I am now converting into PHP.
HTML on the Edit page:
<SPAN class=runner-btnframe><SPAN class=runner-btnleft></SPAN><SPAN class=runner-btnright></SPAN><A id=submit2 class=runner-button type=button name=submit2 value="Add New Infraction" INPUT>Add New
Infraction</A></SPAN>
Javascript onload event
var ctrlInfraction = Runner.getControl(pageid, 'Infraction');
var ctrlAdditional_Consequence = Runner.getControl(pageid, 'Additional_Consequence');
var ctrlMandatory = Runner.getControl(pageid, 'Mandatory');
document.getElementById("hidesavebutton").style.display = 'none';
ctrlInfraction.on('change', function(e){
ctrlAdditional_Consequence.setValue();
$("a[id^='saveButton']").click();
});
$("#submit2").bind("click", {page: this}, function(e){ var page = e.data.page; page.on('beforeSave', function(formObj, fieldControlsArr, pageObj){ formObj.baseParams['Add New Infraction'] = 1; }, page, {single: true}); page.on('afterSave', function(respObj, formObj, fieldControlsArr, pageObj){ delete formObj.baseParams['Add New Infraction']; }, page, {single: true}); page.saveHn(e); });
$("#submit3").bind("click", {page: this}, function(e){ var page = e.data.page; page.on('beforeSave', function(formObj, fieldControlsArr, pageObj){ formObj.baseParams['Done - Return to ODR'] = 1; }, page, {single: true}); page.on('afterSave', function(respObj, formObj, fieldControlsArr, pageObj){ delete formObj.baseParams['Done - Return to ODR']; }, page, {single: true}); page.saveHn(e); });
After record updated
if ($_REQUEST["submit2"]=="Add New Infraction")
{
header("Location: dbo_ODR_Incident_add.php?mastertable=dbo.ODR_v2&masterkey1=".$values["ODRID"]."&masterkey2=".$values["StudentID"]);
exit();
}
I have also tried changing the green "Add New Infraction" to a "1" and it does not work. I have also tried to add an actual button to the project with a slightly different name:
Client Before
pageObj.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
formObj.baseParams['addanotherinfraction'] = "1";
});
$("#saveButton1").click();
return false;
Server: (empty)
Client After:
if ($_REQUEST["addanotherinfraction"]=="Add Another Infraction")
{
header("Location: dbo_ODR_Incident_add.php?mastertable=dbo.ODR_v2&masterkey1=".$values["ODRID"]."&masterkey2=".$values["StudentID"]);
exit();
}
I receive an "Expected identifier in line 3" error message. I also tried to make it simple in the Client After with:
if ($_REQUEST["addanotherinfraction"]=="Add Another Infraction")
{
header("Location: ..._list.php?a=return");
exit();
}
Any suggestions would be helpful.