You need to sign in to do that
Don't have an account?
sfdc@isha.ax1814
send parameters from vfpage(jquery) to controller through commandlink
Hi Everyone,
I have below vfpage code. iam getting value of daterangevalue onclick action in jquery. i need to send this value to controller after click on save . they are already using the commandlink in the code.
i tried with param but iam geeting blank value in the controller
i need help on to pass "daterangevalue" variable from controller to page .
<input name="dateRangeSelect" id="dateRangeSelect">
<img src="{!$Resource.Downarrowimage}" width="8" height="8" style="margin-left:-16px;margin-top:-2px;position: relative;"/>
</input>
<output id="outputid" type="text" value="daterangevalue1"/>
<script>
$("#dateRangeSelect").daterangepicker({
open: function(event, data) { },
change: function(event, data) {
$("li.ui-menu-item").click(function(){
console.log($(this).text());
$("#outputid").val("Date range : "+$(this).text());
var daterangevalue= ($(this).text());
alert(daterangevalue);
});
var a = '{!daterangevalue}';
alert(a);
<apex:commandLink status="renderLightningSpinner" action="{!saveSettings}" value="Save" reRender="pgMsgPnl" title="Save Setting" style="width:25px;height:25px;" onclick={} >
<apex:param name="daterangevalue" value="" assignTo="{!daterangevalue}"/>
</apex:commandLink>
controller:
public string daterangevalue{get;set;}
public void saveSettings(){
string value=Apexpages.currentPage().getParameters().get('daterangevalue');
system.debug('@@test:'+value);
result: @@test:[blank]
Regards,
Isha
I have below vfpage code. iam getting value of daterangevalue onclick action in jquery. i need to send this value to controller after click on save . they are already using the commandlink in the code.
i tried with param but iam geeting blank value in the controller
i need help on to pass "daterangevalue" variable from controller to page .
<input name="dateRangeSelect" id="dateRangeSelect">
<img src="{!$Resource.Downarrowimage}" width="8" height="8" style="margin-left:-16px;margin-top:-2px;position: relative;"/>
</input>
<output id="outputid" type="text" value="daterangevalue1"/>
<script>
$("#dateRangeSelect").daterangepicker({
open: function(event, data) { },
change: function(event, data) {
$("li.ui-menu-item").click(function(){
console.log($(this).text());
$("#outputid").val("Date range : "+$(this).text());
var daterangevalue= ($(this).text());
alert(daterangevalue);
});
var a = '{!daterangevalue}';
alert(a);
<apex:commandLink status="renderLightningSpinner" action="{!saveSettings}" value="Save" reRender="pgMsgPnl" title="Save Setting" style="width:25px;height:25px;" onclick={} >
<apex:param name="daterangevalue" value="" assignTo="{!daterangevalue}"/>
</apex:commandLink>
controller:
public string daterangevalue{get;set;}
public void saveSettings(){
string value=Apexpages.currentPage().getParameters().get('daterangevalue');
system.debug('@@test:'+value);
result: @@test:[blank]
Regards,
Isha
If you are setting the class variable i.e. daterangevalue the why are you trying to access it as apex page params variable?
Try to directly add daterangevalue in system debug.
For reference: system.debug(‘daterangevalue’ + daterangevalue);
Cheers!!!
Hi Jawid,
my intention here is that, i need to pass below jquery values to controller after click on save . Please help me how i can pass paarametrs from below jquery to controller
<output id="outputid" type="text" value="daterangevalue1"/>
<script>
$("#dateRangeSelect").daterangepicker({
open: function(event, data) { },
change: function(event, data) {
$("li.ui-menu-item").click(function(){
console.log($(this).text());
$("#outputid").val("Date range : "+$(this).text());
var daterangevalue= ($(this).text());
alert(daterangevalue);
});
Regards,
Isha
Try this out :
<script> $("#dateRangeSelect").daterangepicker({
open: function(event, data) { },
change: function(event, data) {
$("li.ui-menu-item").click(function(){
console.log($(this).text());
$("#outputid").val("Date range : "+$(this).text());
var daterangevalue= ($(this).text());
doStuff(myParam)l
alert(daterangevalue);
});
</script>
<apex:actionFunction name="doStuff" action="{!doStuff}">
<apex:param name="x" value="x" assignTo="{!somevariable}" />
</apex:actionFunction>
For Reference : http://www.jitendrazaa.com/blog/salesforce/passing-parameter-in-actionfunction-in-visualforce/
Cheers!!!!!