2012-03-27 3 views
1

아래 function of javascript을 사용하여 drop down 값이 변경되면 radio buttonstextbox을 사용 또는 사용 중지합니다.
시작은 괜찮지 만 제출 버튼을 클릭하면 제출시 myindex = 8 or 9이 작동하지 않습니다.
radio button filter[0] and filter[1]은 사용 중지되어야하며 textfield count을 사용하도록 설정해야합니다. 드롭 다운을 선택하고 제출 버튼을 클릭하는 동안이 기능을 호출해야합니다.
나는 그것이 왜 작동하지 않는지 모른다. 어떤 도움.자바 스크립트의 기능이 두 번째로 작동하지 않습니다

function OnChange(dropdown) { 
    var myindex = dropdown.selectedIndex; 

    document.form.filter[0].disabled = false; 
    document.form.filter[1].disabled = false; 

    if (myindex == 8) { 
     document.form.filter[0].disabled = true; 
     document.form.filter[1].disabled = true; 
     document.form.count.disabled = false; 
     document.form.submit.disabled = false; 
    } else if (myindex == 9) { 
     alert("in ALL"); 
     document.form.filter[0].disabled = true; 
     document.form.filter[1].disabled = true; 
     document.form.count.disabled = true; 
     document.form.submit.disabled = false; 

     alert(document.form.filter[0].disabled); 
    } 

    else { 
     document.form.filter[0].disabled = false; 
     document.form.filter[1].disabled = false; 
     document.form.count.disabled = true; 
     document.form.submit.disabled = false; 
    } 
} 

아래 HTML 코드는 다음과 같습니다.

<s:form action="crInquiry" name="form" > 
    <table align="center" width="1020"> 
     <tr> 
      <td>Batch Id : <s:property value="batchId" /> 
       <fieldset 
        style="background-color: #F7F9F3; margin: 2px; padding: 8px; -moz-border-radius: 5pt; border: 1px solid #A7CBE3;"> 
        <legend class="field_label"> 
         <strong>Inquiry Log Status</strong> 
        </legend> 
        <table border="0" id="main_table1" cellpadding="5" width="1010" 
         cellspacing="5" align="center"> 
         <tr style="height: 5px;"> 
          <td width="300" height="2" align="left" colspan="0"><s:hidden 
            name="batchId" id="batchId" 
            onfocus="OnChange((this.form.filterValue));" 
            value="%{ batchId }"></s:hidden> <s:select 
            cssClass="bulkSelect" name="filterValue" 
            label="Search Criteria" required="true" theme="css_xhtml" 
            labelposition="bottom" tabindex="2" list="headerList" 
            onchange="OnChange(this.form.filterValue);" /> 
          </td> 


          <td width="180"><s:radio name="filter" 
            requiredposition="right" 
            list="#{'STATUS_FILTER_START':'START','STATUS_FILTER_END':'END'}" 
            label="Stage" labelposition="right" theme="css_xhtml" 
            tabindex="9" labelposition="bottom"></s:radio> 
          </td> 
          <td width="50" height="2"><s:textfield disabled="true" 
            value="0" name="count" size="2" labelposition="1" 
            theme="css_xhtml"></s:textfield> 
          </td> 
          <td width="180"><s:radio name="order" 
            requiredposition="right" list="#{'ASC':'ASC','DESC':'DESC'}" 
            label="Order" labelposition="right" theme="css_xhtml" 
            tabindex="9" labelposition="bottom"></s:radio> 
          </td> 
          </td> 


          <td width="50"><s:submit theme="css_xhtml" value="Filter" 
            align="left" onclick="gotopage('FilteredInquiryLog');"></s:submit> 
          </td> 
          <td width="59"><s:submit theme="css_xhtml" value="Details" 
            onclick="gotopage('crInquiry')"></s:submit></td> 

         </tr> 


        </table> 
       </fieldset> 
      </td> 
     </tr> 

    </table> 
</s:form> 

와 내가 위의 js 함수를 호출 곳에서 JS 함수를 호출 제출에서

function gotopage(actionname) { 
     document.form.action = actionname + ".action"; 
     document.form.submit(); 
     OnChange(document.form.filterValue); 

    } 
+1

관련 HTML을 표시하고 제출 작업에서이 함수를 호출하는 코드를 표시하십시오. – jfriend00

+0

@Nivesh : 어떻게하면 누군가가 당신을 도울 수있는 충분한 정보라고 생각할 수 있습니까? – bernie

+0

@bernie 제발, 관련 코드를 추가했습니다. –

답변

0

그것은 당신이 양식을 제출 한 후 필드를 조작하려고 할 것이 이상한 것 같다 ...

function gotopage(actionname) { 
     document.form.action = actionname + ".action"; 
     document.form.submit(); 
     OnChange(document.form.filterValue); 

    } 

아마도 당신이 필요로하는 무엇을 :

function gotopage(actionname) { 
     OnChange(document.form.filterValue); 

     document.form.action = actionname + ".action"; 
     document.form.submit(); 
    } 
관련 문제