ColdFusion how to set form input values from the results of a cfquery?

前端 未结 2 1192
夕颜
夕颜 2021-01-22 15:01

Question: (part 1) I am looking for the most efficient way to set my form input values based on the results of my cfquery. My form fields all match

相关标签:
2条回答
  • 2021-01-22 15:53

    Please try the following jQuery code snippet.

    var selDefualtVal = '#getFormData.product_category#';
    jQuery(document).ready(function () {
             jQuery("#product_category option[value='"+selDefualtVal+"']").attr("selected","selected");
    });
    
    0 讨论(0)
  • 2021-01-22 15:57

    for select you can try a comparison for each option values like:

       <select name="product_category" id="product_category">
            <option value="ts8-it" <cfif CompareNoCase(getFormData.product_category,"ts8-it") EQ 0>selected="selected"</cfif> >TS8-Data Center </option>
    

    Same way you can try the radio fields,

      <input id="rails_yes" type="radio" name="19_Rails" value="yes" <cfif getFormData.19_Rails>checked="checked"</cfif> > 
    
      <input id="rails_no" type="radio" name="19_Rails" value="no" <cfif NOT getFormData.19_Rails>checked="checked"</cfif> > 
    
    0 讨论(0)
提交回复
热议问题