I'm trying to add a lookup field inside a pageblocktable iteration component.
I have the following code:
VF:
<apex:column headerValue="Contact" headerClass="ct" >
<apex:inputField value="{!c.Contactid}" id="inputField"/>
<apex:inputHidden id="hdnField" value="{!contactId}" />
<apex:commandLink value="+" styleClass="btn" style="color:red;font-size:15px;" onclick="setVar();" action="{!updateCase}" >
<apex:param name="caseId"
value="{!c.Id}"
assignTo="{!caseId}" />
<apex:param name="contactId"
value="{!contactId}"
assignTo="{!contactId}" />
</apex:commandLink>
</apex:column>
Javascript:
function setVar(){
j$ = jQuery.noConflict();
var newId = j$('[id$=inputField_lkid]').attr( "value" )
j$('[id$=hdnField]').val(newId);
}
Apex Controller:
public Case currentCase{get;set;}
public Id caseId {get;set;}
public void updateCase() {
this.currentCase = [SELECT Id FROM Case WHERE Id = :caseId];
currentCase.ContactId = this.contactId;
update currentCase;
}
However when I click the button the new contact ID is not being passed to the controller, instead it's a blank value(case Id works fine). Does anybody have an idea where I'm going wrong?