You need to sign in to do that
Don't have an account?

Passing Javascript variables to wrapper class
Hi All,
I am currently working on a Apex class, That's perform different functionalities.
Like pagination, search by keyword, and selecting the records and sending some of the data to second page. And in second page have some input text fields that were not a object fileds inturn they are individual fields which will autopopulate with default values when redirected from first page. Now here i need to enter the data for some input fields and on button click it will calculate the rest of the inpit fileds based on the data provided. Fot this calculation and passing the data i am writing a javascript junction. Here i am coming up with a problem.
The problem is-
the values that were calculated in page using javascript were not passing to controller. Please can anyone help me on how to acomplish this task..
Here i have a pageblock table records that needs to be passed to controller.
Thank You.
I am currently working on a Apex class, That's perform different functionalities.
Like pagination, search by keyword, and selecting the records and sending some of the data to second page. And in second page have some input text fields that were not a object fileds inturn they are individual fields which will autopopulate with default values when redirected from first page. Now here i need to enter the data for some input fields and on button click it will calculate the rest of the inpit fileds based on the data provided. Fot this calculation and passing the data i am writing a javascript junction. Here i am coming up with a problem.
The problem is-
the values that were calculated in page using javascript were not passing to controller. Please can anyone help me on how to acomplish this task..
Here i have a pageblock table records that needs to be passed to controller.
Thank You.
In 2nd page,you just need to fetch what's there in 'id' param and then you are good to go.
If this helps,please mark it as best answer to help others :)
Hope this answers your question..
Thank You
here i have 2 pages using the same controller-
First page-
<apex:page Controller="accountnew" id="thePage">
<script type="text/javascript">
function total(index){
alert('hi');
for(i=0;i<=index;i++)
{
document.getElementById('thePage:theForm:thePageBlock:theVar:thePageBlockTable:'+i+':hiddenField').value = 'this is a description';
alert('new');
}
}
</script>
<apex:form id="theForm">
<apex:pageBlock id="thePageBlock">
<apex:variable value="{!-1}" var="index" id="theVar">
<apex:pageBlockTable title="Products" value="{!account}" var="l" id="thePageBlockTable">
<apex:column >
<apex:inputtext value="{!l.name}"/>
</apex:column>
<apex:column >
<apex:inputtext value="{!newdesc}" id="hiddenField"/> /* (Note---------------------> newdesc is not a account object field */
<apex:variable value="{!index+1}" var="index"> </apex:variable>
</apex:column>
</apex:pageBlockTable>
<input type="button" value="Total" onClick="total('{!index}');"/>
<apex:commandButton value="save" action="{!newpage}"/>
</apex:variable>
</apex:pageBlock>
</apex:form>
</apex:page>
Second Page-
<apex:page controller="accountnew">
<apex:form id="theForm">
<apex:commandButton value="test" action="{!test}"/>
<apex:pageBlock >
<apex:pageBlockTable title="Products" value="{!account}" var="l">
<apex:column >
<apex:inputtext value="{!l.name}"/>
</apex:column>
<apex:column >
<apex:inputtext value="{!newdesc}" id="hiddenField"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Contrller--
public class accountnew {
public String newdesc{get;set;}
public List<Account> getAccount(){
List<Account> rows = new List<Account>();
List<Account> selectlist = ([SELECT Id,Name FROM account limit 10]);
for(account b : selectlist){
rows.add(b);
}
return rows;
}
public void test() {
system.debug('value:'+ newdesc);
}
public PageReference newpage() {
pagereference pricePage = new pagereference('/apex/NewPricePage');
pricePage.setRedirect(false);
return pricePage;
}
}
Here scenario is when i redirect to second page defalut values needs to go in newdesc, that got populated from first page. Now in second when i am changing the newdesc values all are setting to the same value which i don't want...instead for each account name it needs to accept different newdesc.
ex:
From first page i get these results
Name newdesc
AcctA this is a description
AcctB his is a description
etc...
In seconpage i am expecting the results to be when redirected from first page--
Name newdesc
AcctA this is a description
AcctB his is a description
etc...
And now I should have ability to change the "newdesc" to different values and expecting output result is-
Name newdesc
AcctA 9999
AcctB 8888
etc...
But i am getting the results as-
Name newdesc
AcctA 9999
AcctB 9999
etc...
How to resolve it..Please help.
I would suggest to use different variable for both the textboxes.