You need to sign in to do that
Don't have an account?
Sandeep Yadav
I stucked to pass the inputfiled value to the controller using javascript
Hi everyone,
Here is my code--
when I debug it shows null value.
Any suggestion ??
Here is my code--
when I debug it shows null value.
Any suggestion ??
<apex:page controller="AlertConId" > <script type="text/javascript"> function demo(fst,lst) { var fn = document.getElementById(fst).value; var ln = document.getElementById(lst).value; myFunction(fn,ln); } </script> <apex:form > <apex:actionFunction name="myFunction" action="{!save}"> <apex:param value="" name="fname" assignTo="{!fname}"/> <apex:param value="" name="lname" assignTo="{!lname}"/> </apex:actionFunction> <apex:pageBlock id="ref"> <apex:pageBlockSection > <apex:inputText id="fname" label="FirstName"/> <apex:inputText id="lname" label="LastName"/> <apex:commandButton value="Go" onclick="demo('{!$Component.fname}','{!$Component.lname}')" reRender="ref"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> ------------------------------------------------------------------------------------------------------------ public class AlertConId { public Contact ct {get;set;} public string fname {get;set;} public string lname {get;set;} public void save() { string first = ApexPages.currentPage().getParameters().get('fname'); string last = ApexPages.currentPage().getParameters().get('lname'); system.debug(first + last); ct = new Contact(); ct.firstname = first; ct.lastname = last; try{ insert ct; } catch(Exception e){} } }
Hope this will help yo.
Thanks
Vinod
When you have set the value in the variables with the help of the param then why did you tried to get it from the URL. You should directly use the variables as set in the page. Please change your code as below :
Please let us know if you need any further information or help on this.
Thanks,
Abhishek Bansal.