You need to sign in to do that
Don't have an account?
shinerajb
javascript variable to apex variable
how do i pass a javascipt variable into apex variable.
Like i get the id corresponding to a checkbox in javascipt .how do i reflect it into apex varible
Regards
Shine
You can use <apex:actionFunction> tag in visualforce page which can be called from javascript and pass that javascript variable in that function and then in controller you can get that javascript variable and assign it to Apex variable.
All Answers
YOu might wanna check this out:
http://th3silverlining.com/2009/09/14/passing-javascript-values-to-apex-code/
- anup
You can use <apex:actionFunction> tag in visualforce page which can be called from javascript and pass that javascript variable in that function and then in controller you can get that javascript variable and assign it to Apex variable.
Use javascript remoting.
It's the bee's knees.
My apex code is given i want to display the value of include2 on button click it is not working.
with regards
Shine
------------Apex code---------
public string timestampValue{get;set;}
public new2(){
timeStampValue = 'm';
}
public void sendTimestamp()
{
timestampValue='timestampValue--' + timeStampValue;
//system.debug('timestampValue' + timeStampValue);
}
}
------------Apex code---------
-------------javascript code---------
var include2='';
function showIndustriesId(theId,obj)
{
if(obj.checked)
{
include2=include2.concat((','+theId));
alert(include2);
}
else
{
include2=include2.replace((','+theId),'');
alert(include2);
}
}
function sendTimeStamp()
{
var timeStamp=include2;
sendTimeStamp(timeStamp);
}
-------------javascript code---------
-------------visual force---------
<apex:form >
<apex:commandButton value="pass" onclick="sendTimeStamp()"/>
<apex:actionFunction name="sendTimeStamp" action="{!sendTimeStamp}" >
<apex:param name="x" value="" assignTo="{!timeStampValue}" />
</apex:actionFunction>
</apex:form>
-------------visual force---------
Hai,
How can we use this javascript remoting.