You need to sign in to do that
Don't have an account?
![justin_sfdc justin_sfdc](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
<apex:inputfield>
Can I give an "id" the value in following manner while using <apex:inputfield> component?
<apex:inputField value={!x} id ="{!value}" />
What am trying to achieve here is; I have this inputField inside an <apex:repeat> component and I need to give it a separate id everytime this component gets repeated.
Any suggestion is helpful.
Thanks ~ justin_sfdc
Hi,
Is this what you are looking for?
All Answers
Hi,
Currently it's not possible to use an expression as an ID for a visualforce component. There is an Idea to support that @ https://success.salesforce.com/ideaview?id=08730000000Bqu1AAC
I think you can use this.
apex:variable
Thanks,
Samba
Hi,
Thanks for the reply. I see that we can achieve it using the generic html input field.
Could you give me an example of how i would be using <apex: repeat> component and html input field at the same time.
and the id value in it should be in incrementing order. for example; if we are entering an address in the field then the id for it should be id="address{!number}", where the number will increased by one everytime the repeat coomponent is called.
Thanks a lot!
justin~sfdc
Try having a function in your controller or extension which increments an integer and return the string value of that integer. Instead of creating input field using VF try using the HTML code.
<input type="text" name="Account" id="{!y}" value="{!x}"></input>
where {!y} is the method that return the incremented Integer value in a String format(using String.valueof(Integer))
and {!x} is the method that processes your input value.
with regards,
Sgt_Killer
Hi,
Is this what you are looking for?
Hi,
On doing this, I get an error message saying Attribute "value" was already specified for element "apex:variable"
I am utilizing this component outside the repeat component and again inside the repeat component with the var being "rowNum" just like the one you showed.
Any mistake am i doing in here?
Thanks and Regards,
Justin~sfdc
Hi,
Please disregard my previous email. I was able to get different id's everytime the repeat component is executed.
Thanks a lot!
Justin~sfdc
Hi Amarcute,
With your help I am able to achieve separate id's in the repeat block. However, I could not direct the input tag to the SFDC custom field.
For example; If i have a custom Object called as "Address__c" and there is a field called "country__c"
Now in the input tag; whatever value the user inputs; i want to save it in that field. How would I do it?
So far I have;
<apex:variable value={!0} var ="rowNum" />
<apex: repeat value= {!myList}" var="f">
<apex:outputLabel value="country" for ="Country" />
<input id="Country{!rowNum}" required="true" /> //How do i direct it to the country__c field in Address__c object?
Thanks a lot!
Justin~sfdc