I am having trouble passing values via Javascript.
APEX PAGE:
//STUFF HERE
<b>First Goal:</b><br /><br />
Goal:<apex:inputField id="Goal" value="{!Account_Plan__c.Goal1__c}" /><br />
<b>Second Goal: </b><br /><br />
Goal:<input id="Goal2" /><br />
<b>Third Goal: </b><br /><br />
Goal:<input id="Goal3" /><br />
Strategy to Achieve Goal:<input id="strat" type="text" size="90"/>
<script type="text/javascript">
function newtask() {
AddTask(
document.getElementById("strat").value,
document.getElementById("Goal").value,
document.getElementById("Goal2").value,
document.getElementById("Goal3").value
);
}
</script>
<apex:actionFunction name="AddTask" action="{!AddTask}">
<apex:param name="strat" value="" />
<apex:param name="Goal" value="" />
<apex:param name="Goal2" value="" />
<apex:param name="Goal3" value="" />
</apex:actionFunction>
Controller
...OTHER CODE AND CONSTRUCTOR..
Public Pagereference AddTask(){
// String taskdate = Apexpages.CurrentPage().GetParameters().get('tdate');
// Date d = date.valueof(taskdate);
String goal = Apexpages.currentPage().getParameters().get('goal');
String goal2 = Apexpages.currentPage().getParameters().get('Goal2');
String goal3 = Apexpages.currentPage().getParameters().get('Goal3');
String strat = Apexpages.currentPage().getParameters().get('strat');
List<Account_plan__c> a = new List<Account_plan__c>();
a = [Select account__c from Account_plan__c where id = :CurrentAcct];
Ntask = new Task();
Ntask.ActivityDate = date.parse('5/25/13');
Ntask.Subject = strat;
Ntask.OwnerId = CurrentUser;
Ntask.WhatId = a[0].account__c;
Ntask.Status = 'In Progress';
Ntask.Priority = 'Normal';
Ntask.Type = 'Call';
Ntask.Goal_Name__c = goal;
try{
insert Ntask;}
catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was an Error! Cannot Create Task'));
Ntask.addError(e.getMessage());
} finally {
System.debug('Insert Task Error');
}
SearchTact();
return null;
}
This code works without passing parameters, if I were to preset the variables in my controller. I have already tested it. I tried passing them with Javascript and it's not working at all.
Any help would be great.