function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MarinaMartinMarinaMartin 

Can't Override SelectList ID

Hello,

 

I'm stumped on this one. I set a SelectList ID in my Visualforce page, but when I view source, it's replaced with a much longer ID. This is causing a problem because this select list is a search box, so if the ID is wrong it's not passed to the search in the controller.

 

// Controller code that creates selectList options

public List<SelectOption> getTheAnalysts() {
List<SelectOption> analystoptions = new List<SelectOption>();
analystoptions.add(new selectOption('', ''));
for (User users : [SELECT Id, Name FROM User WHERE IsActive = true]) {
analystoptions.add(new selectOption(users.Id, users.Name));
}
return analystoptions;
}

 

// Visualforce display of selectList

<tr>
<td style="font-weight:bold;">Analyst<br/>
<apex:selectList id="analyst" size="1" value="{!theAnalyst}" onchange="doSearch();">
<apex:selectOptions value="{!theAnalysts}" />
</apex:selectList>
</td>
</tr>

 

// View source display of selectList

<tr>

<td style="font-weight:bold;">Analyst<br /><select id="j_id0:j_id27:mainresults:j_id59:analyst" name="j_id0:j_id27:mainresults:j_id59:analyst" size="1" onchange="doSearch();">

<option value="" selected="selected"></option>

<option value="XXXXX">User One</option>

<option value="XXXXX">User Two</option>

</select>

</td>

</tr>

 

Where is the start of that ID coming from? And how do I suppress it??

 

Thanks for any insight.

 

Marina

abhishektandon2abhishektandon2

I Its a Functionality of SFDC to generate id;s dynamically.

 

this id of the component become the nested id

 

for example VF page

 

<apex:outputpanel id="a">

<apex:outputpanel id="b">

<apex:outputpanel id="c">

....

</apex:outputpanel>

</apex:outputpanel>

</apex:outputpanel>

 

so when this wil render, you see in view source

 

<span id="a">

<span id="a:b">

<span id="a:b:c">

</span>

</span>

</span>

 

If yo want to access the value of element in Id C

then use $Component.c this will give you id of element of c