2013-07-16 3 views
0

내 웹 사이트에 기본 양식을 삽입하여 사용자가 조리법을 검색 할 수있게하려고합니다. 폼에서 입력 값을 찾기 위해 자바 스크립트를 얻는 데 어려움을 겪고 있습니다. 어떤 도움을 주시면 감사하겠습니다.getElementById()가 작동하지 않습니다.

<!DOCTYPE html> 
<html> 
<head> 
<script> 
    function searchURL() 
{ 
    var foodSearch = window.open("http://search.myrecipes.com/search.html?N=17&mFil=false&Ntt=" + "document.getElementById("searchFood").value"); 

}; 
    </script> 
    </head> 

<body> 

<form> 

<fieldset> 
<legend>Search for Healthy Diet Recipes</legend> 
<p> 
Type in the name of the Recipe or Healthy Diet Food you would like to cook below:<br> 
</p> 
<br> 
<input type="text" id='searchFood' > 
<input type="button" value="Find Delicious Food" onClick="searchURL()"> 

</fieldset> 
</form> 
</body> 

</html> 
+0

당신이 당신의 콘솔에서 오류보고 했습니까? 그것은 시작할 수있는 좋은 장소가 될 것입니다. – epascarello

+1

[** debug ** JavaScript] (http://www.netmagazine.com/tutorials/javascript-debugging-beginners)에 대해 자세히 알아보십시오. –

답변

5

"" 따옴표에 추가하지 마십시오.

사용이 :

var foodSearch = window.open("http://search.myrecipes.com/search.html?N=17&mFil=false&Ntt=" + document.getElementById("searchFood").value); 
관련 문제