2010-04-29 2 views
1

CFFORMCFINPUT 태그가 있습니다. 페이지를 게시하지 않고 범위를 동적으로 설정하려고합니다. 나는 기본적으로 범위를 "1"과 범위의 maxValue를로의 MINVALUE을 설정하려면, 위의 CFFORM에서AJAX 호출을 사용하여 CFINPUT에서 범위 속성의 최대 값을로드 할 수 있습니까?

<cfselect id="this" name="this" bind="cfc:Data.getThis()" bindonload="true" /> 

<cfselect id="that" name="that" bind="cfc:Data.getThat({p1})" /> 

<cfselect id="theOther" name="theOther" bind="cfc:Data.getTheOther({p1}, {p2})" /> 

<cfdiv 
    id="maxQty" 
    bind="cfc:Data.getMaxQty({itemId})" /> 

<cfinput 
    type="text" 
    id="qty" 
    name="qty" /> 

<cfdiv 
    id="itemId" 
    bind="cfc:Data.getItemId({this}, {that}, {theOther})" /> 

: 나는 몇 AJAX는 동적으로 즉석에서 양식 필드를로드 할 페이지를 통해 통화를 할 cfc:Data.getMaxQty({itemId})의 값

이것이 가능합니까? 내가 어떻게 해?

답변

1

빠른 대답은 "아니오"입니다. 그러나 매우 쉬운 해결 방법이 있습니다.

<script type="text/javascript"> 
<!-- 

function validateForm() { 
    var maxQty = document.getElementById("maxQty").innerHTML; 

    if (document.myForm.add_item_1.value < 1 || document.myForm.add_item_1.value > maxQty) { 
     alert("Quantity must be an integer value between 1 and " + maxQty); 

     return false; 
    } 

    return true; 
} 

//--> 
</script> 

<cfform name="myForm" method="post" action="myFormAction.csm" onsubmit="return validateForm();"> 

<cfdiv 
    id="maxQty" 
    bind="cfc:Data.getMaxQty({itemId})" /> 
: 양식을 제출할 때 단순히 당신이 바인딩을 사용하여 CFDIV 또는 CFINPUT 숨겨진 필드에 최대로 원하는 값을로드 한 후 최소/최대 값을 검증하는 자바 스크립트 함수에서 그 값에 액세스
관련 문제