绑定/更改如何显示行

问题描述:

我有一个表单使用ColdFusion,目前正在使用绑定来生成一个值。用户从下拉菜单中选择后,会自动生成一个表格生成的值'Y'或'N'。我需要做的是使用该值,在这种情况下,如果值为'Y'则显示更多需要回答的问题。这是当前编码的样子。绑定/更改如何显示行

<td>Select Category: 
    <cfselect name="catdesc" 
    title="Select category to generate related services" 
    bind="cfc:servicetype2.cat_description()" 
    bindonload="true"/><br /> 
</td> 
</tr>            
<tr id="serv_ty2" style="display: inline;"> 
    <td></td> 
    <td>Select Service: 
    <cfselect name="service_type" 
    bind="cfc:servicetype2.getServiceType2({catdesc})" 
    bindonload="false"/></td> 
</tr> 
<tr id="lr_verify" style="display: inline;"> 
    <td></td> 
    <td>Labor Relations Required: 
    <cfinput name="lr_needed" <!--- 
    onchange="document.getElementById('lr_question').style.display = (this.selectedIndex == Y) ? 'inline' : 'none'"---> 
    bind="cfc:servicetype2.getLR({service_type})" 
    onchange="editLR()" 
    bindonload="false"/></td> 
</tr> 

这是我想说明如果Y产生

<TR id="lr_question" name="lr_question" style="display: none;"> 
    <td align="left" nowrap>nbsp;<b>Additional Question:</b><br>(Hold Ctrl to select multiple)</td> 
    <td align="left">Question:<br><br> 
    <select id="lr_quest" name="lr_quest" multiple="multiple" required="NO" size="5"> 
    <option name="abc" id="abc"> 
    Choice 1</option> 
    <option name="abc2" id="abc2"> 
    Choice 2</option> 
    </select> 

从我的研究,我尝试了两种解决方案的其他问题,但没有工作,我假设我有不正确的语法或我的想法是正确的。

这里是尝试Java函数是什么:

function editLR() 
{ 
    // if 'Y' then additional questions for service type should show 
    var lrshow = document.getElementById("lr_needed"); 
    if(lrshow == 'Y') { 
    lr_question.style.display = "inline";   
    } 
    else if (lrshow == 'N') { 
    lr_question.style.display = "none"; 
    } 
    else if (lrshow == '') { 
    lr_question.style.display = "none"; 
    } 
} 

让我知道,如果你有我道歉,如果我没有正确地解释自己的任何建议。在此先感谢您提供的任何帮助,我仍然对JavaScript和Coldfusion不熟悉,以便了解仍然可用的所有元素。

要开始,你有这样的:

var lrshow = document.getElementById("lr_needed"); 

添加此行后,看看你会得到什么。

alert("lrshow is " + lrshow); 

然后看看是否有什么差别:

var lrshow = document.getElementById("lr_needed").value; 
alert("lrshow is " + lrshow);