2016-08-09 1 views
1

나는 목록을 반복하고 콩을 사용하여 값을 표시하고있다 : 난 내 행 세부 사항을 캡처하는 onfocus 및 이벤트를 사용하고 같은수없는 <논리 : 반복 처리>

코드 뭔가를 사용하고 쓰기 이 :

<logic:iterate id="empList" name="search" property="empList" indexId="index"> 
     <tr> 
      <td> 
       <span id="empid"><bean:write name="empList" property="empID"/></span> 
      </td> 

      <td> 
       <bean:write name="empList" property="firstName"/> 
      </td> 

      <td> 
       <bean:write name="empList" property="lastName"/> 
      </td> 

      <td> 
       <html:button property="View" value="View" onfocus="viewPage()"/>   
      </td> 
     </tr> 
</logic:iterate> 


<script> 
function viewPage(){ 
var empid = document.getElementByID("empid).innerHTML; 
} 
</script> 

하지만 난 그것이 DgetElementId()입니다 변수 당신이 잘못된 함수 이름을 사용하는 것

+0

파싱 된/브라우저 렌더링 된 HTML을 공유하십시오. [문서에서 동일한 'id'값을 갖는 여러 요소가 없어야합니다 .___] (https : // www .w3.org/TR/html-markup/global-attributes.html # common.attrs.id) – Rayon

답변

0

도와주세요 내 자바 스크립트 EMPID 값을 얻을 수 아니다 소문자로 쓰면 큰 따옴표가 닫히지 않습니다.

사용이

var empid =document.getElementById("empid").innerHTML;

https://jsfiddle.net/cLL70bmq/

0

세트 = "true"로 각 필드를 인덱싱하여 JS를 JS

<html:form action="something"> 
    <logic:iterate id="empList" name="search" property="empList" indexId="index"> 
       <tr> 
        <td> 
         <span id="empid"><html:text name="empList" property="empID" styleId="empId" indexed="true"/></span> 
        </td> 

        <td> 
         <bean:write name="empList" property="firstName" indexed="true"/> 
        </td> 

        <td> 
         <bean:write name="empList" property="lastName" indexed="true"/> 
        </td> 

        <td> 
         <html:button property="View" value="View" indexed="true" onfocus="viewPage(<bean:write name='index'/>)"/>   
        </td> 
       </tr> 
     </logic:iterate> 
</html:form> 

값을 가져오고 업데이트 할 양식 요소를 취할

<script> 
function viewPage(x){ 
var empid = document.forms[0].empId[x].value; 
} 
</script> 

희망 하시겠습니까?

관련 문제