You need to sign in to do that
Don't have an account?
can't be able to pass the vf components id to jquery
hi all ,
I am quite new to salesforce . i am just creating a mobile app that can just manage accounts and Related contacts.
basically i want to add a functionality in my app such that user can be able to create new account by giving their desired value in the form .
now whne i use html tags like <input id="website" name="website" type="text" /> . jquery process that id easily.
viz var website=$j('#website').val();
but when i try to use <apex:inputfield id="website" value="acc.website"> or <apex:inputtext id="website" value="{!website}"/>
where website is defined in controller with proper getter and setter method.
so as to engaage salesforce field . the error arises that this tag can only be used with sfobjects.
can anyone help me out in passing any vf components id to jquery and retrieve that value in jquery .
any help in this regard would be much appreciated .
-----------------
Thanks and Regards
Anchal Garg
anchal56.er@gmail.com
Anchal
" j-id0 :fm:" is salesforce generated Id's. Whenever you write something like <apex:inputfield value="{!any}"/>. Here you don't set any id for inputfield so when the apex page will render salesforce gives a unique id to it. like j_id0 or j_id1 and it'll always same untill you will not insert any extra element (apex:outputpanel or any ape tag). Format of the id is always like this. Pageid:formid:apx_element1:apex_element2. Suppose you created a page like this.
<apex:page id="pg">
<apex:form id="frm">
<apex:outputpanel id="opPanel" layout="block">
Test Div
</apex:outputpanel>
<apex:form>
</ape:page>
your div's id will be "pg:frm:opPanel"
Jquery don't allow ":" in id's so it's not able to find id's in salesforce format. For jqury you have to write $(document.getElementById('pg:frm:opPanel'));
[If you got answer from my post please mark it as solution.]
Thanks,
Kc
All Answers
Hi Anchal
Try this for your account name input box
$(document.getElementById('j_id0:fm:accountname'));
Let me know if you still have problem.
With Best
Kc
Hi Kapil ,
Thanks for your reply. This code snippet does the same thing as I require.
$(document.getElementById('j_id0:fm:accountname'));
can you clear my doubt in your code
what's this j-id0 :fm: stands here ??
I also sort this problem out by using this code
var accountname=$j('input[id*="accountname"]').val();
Anchal
" j-id0 :fm:" is salesforce generated Id's. Whenever you write something like <apex:inputfield value="{!any}"/>. Here you don't set any id for inputfield so when the apex page will render salesforce gives a unique id to it. like j_id0 or j_id1 and it'll always same untill you will not insert any extra element (apex:outputpanel or any ape tag). Format of the id is always like this. Pageid:formid:apx_element1:apex_element2. Suppose you created a page like this.
<apex:page id="pg">
<apex:form id="frm">
<apex:outputpanel id="opPanel" layout="block">
Test Div
</apex:outputpanel>
<apex:form>
</ape:page>
your div's id will be "pg:frm:opPanel"
Jquery don't allow ":" in id's so it's not able to find id's in salesforce format. For jqury you have to write $(document.getElementById('pg:frm:opPanel'));
[If you got answer from my post please mark it as solution.]
Thanks,
Kc
Thanks kapil for clearing the doubt.... :)