댓글 검색 목록

[javascript] 다음 양식의 성과 이름을 얻기위한 JavaScript 함수를 작성하십시오.

페이지 정보

작성자 운영자 작성일 17-12-30 20:50 조회 1,210 댓글 0

HTML :

<!DOCTYPE html>
<html><head>
<meta charset=utf-8 />
<title>Return first and last name from a form - 365ok.co.kr</title>
<style type="text/css">
body {margin: 30px;}
</style> 
</head><body>
<form id="form1" onsubmit="getFormvalue()">
First name: <input type="text" name="fname" value="David"><br>
Last name: <input type="text" name="lname" value="Beckham"><br>
<input type="submit" value="Submit">
</form>
</body></html>


JS :

function getFormvalue()

{

  var x=document.getElementById("form1");

  for (var i=0;i<x.length;i++)

  {

   if (x.elements[i].value!='Submit')

    {  

      console.log(x.elements[i].value);

     }  

   }

}

댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

코리아뉴스 2001 - , All right reserved.