JavaScript

210923_select+url

요옫 2021. 9. 23. 15:44

(방법1)

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

</head>

<body>

<form action="" name="frm" method="post">

  <select name="list" onchange="location=document.frm.list.value">

    <option>선택</option> 

    <option value="http://www.naver.com">Naver</option>

    <option value="http://www.google.com">Google</option>

    <option value="http://www.nate.com">Nate</option>

  </select>

</form>

</body>

</html>

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

(방법2)

 

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<script type="text/javascript">

  function movetoURL(url) {

document.location.href=url;

}

</script>

</head>

<body>

<form action="" name="frm">

  <select name="url" onchange="movetoURL(this.value)">

    <option>선택</option> 

    <option value="http://www.naver.com">Naver</option>

    <option value="http://www.google.com">Google</option>

    <option value="http://www.nate.com">Nate</option>

  </select>

</form>

</body>

</html>

구글 선택시 구글홈페이지로 이동