[SalesForce] not passing value with Onclick function in PgBlockTable

Am nw to salesforce & Need you assistance. I will explain my scenario. I use 2 custom objects Volume and Quality. I have done all part. I have trouble in onClick() function.In a pageblocktable, I have 3 columns: Date Volume and Quality. For a date(for example today) if there are 2 volume values it has to added and aggregated results should be displayed. All that are working fine.
My requirement here is, I have to use a link on the Summed Volume and Quality values so that if i click on the link a PoP up showed appear showing the indiv Volume and Quality value for the specific date. Here is my code

Class:
Here i have declared a String popup_date to assign the return value of param value to JS.
VOLQUAL CLASS
Visualforce Page
Here, please look at the 2 columns section. When i use Outputlink Value as "/apex/VolqualValue" I get a clean n neat output . But when i use a onClick popup() function i get NULL value for date field. VolQualValue is the INDIV values page and VolQualVF is the total values page.
VolQualVF

Javascript:
Value of {!popup_date} returned is NULL. The pop up returns a page with NO value.
javascript

Please let me know how to render VOLQUAL value page as a popup and Date field value rendered in URL through PARAM tag. Thanks in Advance

Best Answer

This Visualforce expression:

var date = '{!popup_date}';

is expanded into (JavaScript) text when the page containing the table is opened and that is presumably a "null" string. (Use your browser's "View Source" to see this once the page is opened.)

When the apex:outputLink is clicked on it may well result in the popup_date field of the controller being set to the date corresponding to the table row but will not change the value already in the JavaScript in the page.

One way to fix this would be to pass the date in each call:

onclick="popup('{!v.theDate}');"

though you would have to deal with the default date format in your JavaScript (unless you also added a wrapper class).

Related Topic