The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!
<select id="FullYear" class="yesno" name="FullYear">
<option value="1">true</option>
<option value="0">false</option>
<option value="?">Uncertain</option>
</select>
I want to use jQuery to change the text of the option values with 1 and 0 from true and false to Yes and No. I've tried to do this with the following jQuery code:$('.yesno [value="1"]').text('Yes');
$('.yesno [value="0"]').text('No');
I've tested this code with a static select option (populated in the html code -- not programatically) and it works, but it does NOT work on the select whose options are populated by binding to the cfc.$('#FullYear').load(function() {
$('#FullYear option[value="1"]').text('Yes');
$('#FullYear option[value="2"]').text('No');
});
<cfcomponent output="false">
<cffunction name="getYesNoUncertain" access="remote" output="no" returntype="query" description="I am used on details.cfm to populate cfselects">
<cfset q=QueryNew("V,D","VarChar,VarChar")>
<cfset QueryAddRow(q,3)>
<cfset q.V[1]="1">
<cfset q.D[1]="Yes">
<cfset q.V[2]="0">
<cfset q.D[2]="No">
<cfset q.V[3]="?">
<cfset q.D[3]="Uncertain">
<cfreturn q>
</cffunction>
</cfcomponent>
<cfform>
<label>y2006</label>
<cfselect id="y2006" name="y2006" bind="cfc:selectqueries.getYesNoUncertain()" value="V" display="D" bindonload="yes" selected="" class="yesno"></cfselect>
</cfform>
<form>
<label>y2007</label>
<select id="y2007" name="y2007">
<option value="1">true</option>
<option value="0">false</option>
<option value="?">Uncertain</option>
</select>
</form>
<script src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#y2006').ready(function() {
$('#y2006 option[value="1"]').text('Yes');
$('#y2006 option[value="0"]').text('No');
});
$('#y2007').ready(function() {
$('#y2007 option[value="1"]').text('Yes');
$('#y2007 option[value="0"]').text('No');
});
});
</script>
<cfselect id="y2008" name="y2008" />
<script type="text/javascript">
$(document).ready(function() {
$('#y2008').append('<option value="1">Yes</option><option value="0">No</option><option value="?">Uncertain</option>');
});
</script>
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
$("#FullYear option[value='0']").attr("