リストの値を自動的にチェックするためにこのCOLDFUSIONコードを見つけました。もしそうでなければ、 "デフォルト"を選択してください。それだけで私にとってはうまくいかない。 これはcfifに入り、スクリプトはページに入れられますが、デフォルトのJQUERY SELECTORは決してSELECTEDとしてマークされません。jqueryを使用してこの選択オプションを見つける方法
#igShutdownTimer option[default="default"]
私はそれがすべきだと思ったようにページが最初に動くときにvalue="60"
を選択しません。
<div class="col-md-12">
<label for="igShutdownTimer">Ignition ShutDown Timer:</label>
<cfset pos = listfind(inputList,"1_uint ")>
<cfif not pos>
<script>
$('##igShutdownTimer option[default="default"]').attr('selected','selected');
</script>
</cfif>
<select form="configDetail" id="igShutdownTimer" name="1_uint" class="form-control" changeName="Ignition ShutDown Timer">
<option value="0" <cfif pos and getParams.value[pos] is "0">selected</cfif>>0 Minutes</option>
<option value="10" <cfif pos and getParams.value[pos] is "10">selected</cfif>>10 Minutes</option>
<option value="20" <cfif pos and getParams.value[pos] is "20">selected</cfif>>20 minutes</option>
<option value="30" <cfif pos and getParams.value[pos] is "30">selected</cfif>>30 Minutes</option>
<option value="40" <cfif pos and getParams.value[pos] is "40">selected</cfif>>40 Minutes</option>
<option value="50" <cfif pos and getParams.value[pos] is "50">selected</cfif>>50 Minutes</option>
<option value="60" <cfif pos and getParams.value[pos] is "60">selected</cfif> default="default">1 Hour</option>
<option value="120" <cfif pos and getParams.value[pos] is "120">selected</cfif>>2 hours</option>
<option value="240" <cfif pos and getParams.value[pos] is "240">selected</cfif>>4 Hours</option>
<option value="480" <cfif pos and getParams.value[pos] is "480">selected</cfif>>8 Hours</option>
<option value="720" <cfif pos and getParams.value[pos] is "720">selected</cfif>>12 hours</option>
<option value="1440" <cfif pos and getParams.value[pos] is "1440">selected</cfif>>24 Hours</option>
<option value="4294967295" <cfif pos and getParams.value[pos] is "4294967295">selected</cfif>>Unlimited</option>
</select>
</div>
これはソースに印刷されるもので、「SELECTED」が「デフォルト」として表示されないことがわかります。
<script>
$('#igShutdownTimer option[default="default"]').attr('selected','selected');
</script>
<select form="configDetail" id="igShutdownTimer" name="9X26889E92489D" class="form-control" changeName="Ignition ShutDown Timer">
<option value="0" >0 Minutes</option>
<option value="10" >10 Minutes</option>
<option value="20" >20 minutes</option>
<option value="30" >30 Minutes</option>
<option value="40" >40 Minutes</option>
<option value="50" >50 Minutes</option>
<option value="60" default="default">1 Hour</option>
<option value="120" >2 hours</option>
<option value="240" >4 Hours</option>
<option value="480" >8 Hours</option>
<option value="720" >12 hours</option>
<option value="1440" >24 Hours</option>
<option value="4294967295" >Unlimited</option>
</select>
ロリーの回答後、誰かがこのリストに<option value="60" default="default">1 Hour</option>
を見つけるために必要なセレクタとdefault="default"
はで表示される場合がありますことを、他のリストで私を助けることができる
の作業コード:
<div class="col-md-12">
<label for="igShutdownTimer">Ignition ShutDown Timer:</label>
<cfset pos = listfind(inputList,"1_uint ")>
<select form="configDetail" id="igShutdownTimer" name="#daCFC.enc('1_uint')#" class="form-control" changeName="Ignition ShutDown Timer">
<option value="0" <cfif pos and getParams.value[pos] is "0">selected</cfif>>0 Minutes</option>
<option value="10" <cfif pos and getParams.value[pos] is "10">selected</cfif>>10 Minutes</option>
<option value="20" <cfif pos and getParams.value[pos] is "20">selected</cfif>>20 minutes</option>
<option value="30" <cfif pos and getParams.value[pos] is "30">selected</cfif>>30 Minutes</option>
<option value="40" <cfif pos and getParams.value[pos] is "40">selected</cfif>>40 Minutes</option>
<option value="50" <cfif pos and getParams.value[pos] is "50">selected</cfif>>50 Minutes</option>
<option value="60" class="default" <cfif pos and getParams.value[pos] is "60">selected</cfif>>1 Hour</option>
<option value="120" <cfif pos and getParams.value[pos] is "120">selected</cfif>>2 hours</option>
<option value="240" <cfif pos and getParams.value[pos] is "240">selected</cfif>>4 Hours</option>
<option value="480" <cfif pos and getParams.value[pos] is "480">selected</cfif>>8 Hours</option>
<option value="720" <cfif pos and getParams.value[pos] is "720">selected</cfif>>12 hours</option>
<option value="1440" <cfif pos and getParams.value[pos] is "1440">selected</cfif>>24 Hours</option>
<option value="4294967295" <cfif pos and getParams.value[pos] is "4294967295">selected</cfif>>Unlimited</option>
</select>
</div>
<cfif not pos>
<script>
$('##igShutdownTimer option.default').prop('selected', true);
</script>
</cfif>
。
おそらく( '選択'、 '選択')の代わりに.ATTRの(真の '選択').prop使用する必要があります...しかし、jQueryの作るように見えることはできませんとにかくこれについて心を整えてください – Tibrogargan