JavaScript getElementByID --> getElementsByName

JavaScript 에서 getElementByID 이 작동되지 않는다면 getElementsByName 사용하도록 하자.

<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script language="javascript">
function button_action(value)
{
alert(value);
//var param = document.getElementById("aaa").value;
//getElementByID 않는다면 getElementsByName 을 사용
//var param = document.getElementsByName("bbb")[0].value;
alert(param);

}
</script>
<input id="aaa" name="bbb" type="text" value="Yoon Byoung Hoon">
<input id="abc" type="submit" value="Execute" onclick="button_action('ysoftman')">

</html>

comments:

댓글 쓰기