You need to sign in to do that
Don't have an account?
javascript issue with passing parameters into function
Hello I am trying to pass two parameters into a javascript function from a table row but I am not getting the values , see below:
The VF page markup calling the function:
<apex:inputHidden id="fprodId" value="{!prod.Id}" rendered="true"/>
<apex:column headerValue="Name">
<apex:outputLink id="fprodName" onclick="closeWin('{!$Component.fprodId}', '{!$Component.fprodName}');" >
{!prod.Name}
</apex:outputLink>
</apex:column>
The javascript function called:
<script>
function closeWin(prodId,prodName) {
alert('ProdID: ' + prodId + ' ProdName: ' + prodName);
// var winMain=window.opener;
// if (winMain ==null){winMain=window.parent.opener;}
// winMain.closeLookupPopup(prodId, prodName);
}
</script>
RESULTS:
when I click the link I see the following:
ProdId:
j_id0:theMainBlocktheForm:theBlock:prodList:fprodId
ProdName:
j_id0:theMainBlocktheForm:theBlock:prodList:0:fprodName
I need to get the actual values from those two fields, I have tried to use all types of combinations of .value .text .innerHTML but with no luck. Any ideas as to what may be the issue??
It didn't work, what I had to do was the following :
<apex:column headerValue="Product" id="prodCol">
<apex:actionRegion id="prodRgn">
<apex:inputText value="{!SOI.Product_Name__c}" id="fProd" onFocus="this.blur()" />
<apex:commandLink onclick="prodLookup(this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].options[this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].selectedIndex].value);" reRender="fProd">
<apex:image value="{!$Resource.lookupIcon}"/>
<apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:actionRegion>
</apex:column>
This is not a pretty way of getting to the value but it worked for me, the problem is that the least change to the layout of the page may leave this not working.
All Answers
You're getting the right ID values. You just need to call document.getElementById( idValue ) to get the node, then you can use .value, .checked, .selectedIndex, etc depending on the type of field you're using.
It didn't work, what I had to do was the following :
<apex:column headerValue="Product" id="prodCol">
<apex:actionRegion id="prodRgn">
<apex:inputText value="{!SOI.Product_Name__c}" id="fProd" onFocus="this.blur()" />
<apex:commandLink onclick="prodLookup(this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].options[this.parentNode.parentNode.cells[1].getElementsByTagName('select')[0].selectedIndex].value);" reRender="fProd">
<apex:image value="{!$Resource.lookupIcon}"/>
<apex:param name="currSOI" value="{!SOI.id}" assignTo="{!currSOIid}"/>
</apex:commandLink>
</apex:actionRegion>
</apex:column>
This is not a pretty way of getting to the value but it worked for me, the problem is that the least change to the layout of the page may leave this not working.